-
April 28th, 2012, 06:52 PM
#1
2D array
I have two textbox that user input string into.
how can i store those two value in 2D array and output,
Thanks,
-
April 30th, 2012, 02:11 PM
#2
Re: 2D array
You are going to have to be more specific but if you are using winapi
you can acquire the text strings from the message EM_GETLINE i believe. There is plenty of documentation online....
http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
you will have to use EM_GETLINEINDEX (i think) beforehand to get the index of the first character. There are examples available on msdn, once again.
-
April 30th, 2012, 02:25 PM
#3
Re: 2D array
Thanks for replying
this is an example but what i am looking for is for user to enter data instead of
Assigning Values
Dim strBooks(4, 1) As String
strBooks (0, 0) = "Learning Visual Basic"
strBooks (0, 1) = "John Smith"
strBooks (1, 0) = "Visual Basic in 1 Week"
strBooks (1, 1) = "Bill White"
strBooks (2, 0) = "Everything about Visual Basic"
strBooks (2, 1) = "Mary Green"
strBooks (3, 0) = "Programming Made Easy"
strBooks (3, 1) = "Mark Wilson"
strBooks (4, 0) = "Visual Basic 101"
strBooks (4, 1) = "Alan Woods"
-
April 30th, 2012, 05:24 PM
#4
Re: 2D array
it also depends on how you are allocating data. so you want a 4x2 array of strings? are you using pointers or STL objects?
char *stringTable[4][2];
char userString[256] = {'\0'};
for(int i = 0; i < 4; i++)
{
for(int j = 0; j <2; j++)
{
cin>> userString;
strcpy(stringTable[i][j], userString);
}
}
Should work...
-
April 30th, 2012, 05:27 PM
#5
Re: 2D array
I am using VB 2010 and Window Form
Will this code work ?
-
April 30th, 2012, 05:30 PM
#6
Re: 2D array
I don't know anything about those. You are probably posting in the wrong forum as this is the graphics section.
-
November 12th, 2012, 01:45 AM
#7
Re: 2D array
We want to store information about what pieces are in which locations. The most natural way to store it would be to index locations by the row and column. This is easily done with a 2-dimensional array:
To declare a 2-D array (of primitive types):
final int BLANK = 0; // location empty
final int WHITE = 1; // white piece
final int BLUE = 2; // blue piece
int board[][] = new int[8][8]; // create 64 integers
board[0][0] = WHITE; // a white piece in row 0, column 0
board[0][1] = BLANK; // row 0, column 1 is empty
board[6][0] = BLUE; // a blue piece in row 6, column 0
Or use a nested loop to load the entire array full of blanks:
for (int i=0; i < 8; i++)
for (int j=0; j < 8; j++)
board[i][j] = BLANK;
-
December 12th, 2012, 01:02 AM
#8
Re: 2D array
The above code must work in Visual Basic.
As "str" is being used for showing "string" in visual basic.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|