Tuesday, July 28, 2009

How to store a string in a matrix in visual basic?

Hello


I have 2 strings of characters that are on a text box on visual basic and I would like to store in a matrix bidimensional. Each character is separated by a blank space, for example if the strings are the following each one on separated lines:


M y h o u s e i s b i g


H e r h o u s e i s b i g g e r


I would like to store in matrix M each character of the string as follows:


M(1,1)=M


M(1,2)=y


M(1,3)=h


M(1,4)=0


M(1,5)=u


until the end of the phrase (or string)


and then it should go to the next line and store in a different matrix the next string as follows:


C(2,1)=H


C(2,2)=e


C(2,3)=r


C(2,4)=h


C(2,5)=o


C(2,6)=u


until the end of string


Can somebody help me to write a code in visual basic(Not visial net, pls) to solve this problem?


Thank you very much

How to store a string in a matrix in visual basic?
If there is a space between each character then





Dim Str() as String


Str = Split("a b c d e", " ")





If there is no space betwwen each character then


Strng = "abcde"


Dim Str(Len(Strng)) as String


For I = 1 to Len(Str)


Str(I) = Substring(Str, I, 1)


Next I


No comments:

Post a Comment