Tuesday, November 16, 2010

How do I split a string array and display the result in a text box using vb .net?

I'm working on an assignment. after joining two strings, I must now use the Split to split the string back to two strings and display the result in a text box.How do I split a string array and display the result in a text box using vb .net?
Well, you said you need to use split to do this. Split takes a string to split, a delimiter to split and (optionally) an integer to limit the amount of times the string will be split and returns an array.

consider this code





Dim myFirstString As String

Dim mySecondString As String

Dim combinedString As String

Dim splitstring As String() ' note that this is an ARRAY of strings





myFirstString = ';hello';

mySecondString = ';world';

combinedString = myFirstString %26amp; '; '; %26amp; mySecondString

'combinedString now holds ';hello world';

' now split the string every time there is a space

splitstring = Split(combinedString, '; ';)

MessageBox.Show(splitstring(0))

MessageBox.Show(splitstring(1))

'alternatively you can use a for each statement to loop through the array

For Each part As String In Split(combinedString, '; ';)

MessageBox.Show(part)

NextHow do I split a string array and display the result in a text box using vb .net?
New_string=Mid$(String,Start,Number_of_c鈥?br>


example:



strc=';Hello World';



new_str1=Mid$(strc,1,5) 'new_str1= ';Hello';



new_str2=Mid$(strc,6) 'new_str= ';World';
  • find an interesting online
  • No comments:

    Post a Comment