To insert a string in to a specific position in this tutorial, I use 3 textboxes and 1 button. as below:
No | Control Type | Name | Text |
1 | Form1 | InsertRemoveString | Insert String |
2 | Textbox1 | TextboxString1 | |
3 | Textbox2 | TextboxString2 | |
4 | Textbox | TextboxString3 | |
5 | Button1 | ButonInsert | Insert String |
Code
Public Class InsertRemoveString
Dim string1 As String
Dim String2 As String
Dim string3 As String
Dim StringMsb As String
Private Sub ButtonInsert_Click(sender As Object, e As EventArgs) Handles ButtonInsert.Click
string1 = TextBoxString1.Text
String2 = TextBoxString2.Text
string3 = TextBoxString3.Text
StringMsb = "String 1 is:" & string1 & " String 3 is: " & string3
StringMsb = StringMsb.Insert(1, String2)
MsgBox(StringMsb)
End Sub
End Class
- StringMsb = StringMsb.Insert(1, String2): Number 1 here is a position which will insert String2(TextboxString2).
- The number will start from 0....and from left to right(eg: 0.1.2.3.4...)
- example:
- TextBoxString1.Text = cat
- TextBoxString2.Text = dog
- TextBoxString3.Text =pig and StringMsb = StringMsb.Insert(1, String2): mean the the Text in TextboxString2 will insert into second character of whole words.
So the Messgage Box will show( cdogatpig).
0 comments:
Post a Comment