|
-
May 25th, 2010, 01:20 AM
#2
Re: Splitting text from numbers.
Hello again! 
You see, you having a need to discard the numbers throws a spanner in the works, but it is not too complicated 
We first need to split the string - I have noticed that there is a comma separating each segment, so we can use the comma as a delimiter. Right, after the split, we would have to test whether or not that segment is numeric or not. If it isn't numeric, then we add it to the label for example :
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyString As String
Dim arrSplit()
MyString = "1234, this, is, text,5678"
arrSplit = MyString.Split(",") 'Split at comma
For i As Integer = 0 To arrSplit.Length - 1 ' loop through each segment
If Not IsNumeric(arrSplit(i)) Then 'if it isn't numeric
Label1.Text = Label1.Text & arrSplit(i) 'add to label
End If
Next
End Sub
I hope it helps
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
|