Software Developer, Equity Analyst, Polymath.
Posts tagged Sample Code
Split Command Sample Code (VB NET)0
by Ray Tawil in Visual Basic.Net
Preparations : 1 Textbox and 1 Button
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strInput As Array 'make array variable Dim strResult1 As String 'text variable Dim strResult2 As String 'another text variable Try strInput = Split(TextBox1.Text, " ") 'split the textbox if there is space. 'you can also use chr(32) to replace " " strResult1 = strInput(0) 'split first text strResult2 = strInput(1) 'split second text MsgBox(strResult1 + strResult2) 'combine first and second text with no space Catch ex As Exception End Try End Sub
Test the code, type space character between 2 words :
What we have done here?
- We have 2 words with a space character (“jenni” and “fer”)
- We split those words using “Split” command into array, the process is identified with space character, so we had 2 lines.
- We combine those words back together in one line, but this time with no space character in it.