Electro121
Technical User
Hi All,
I am very new to VB Script and trying to figure out what is probably a simple issue but can't seem to get the result I want.
I have a small form I have created with 2 multiline text boxes on the left and right hand sides of the form and a couple of buttons.
When I click a button, I want to take the data from each line in one textbox, add a fixed string of data to each line of the textbox on the left, and then output the data to the right hand side textbox.
For example:
Texbox1 - Data entered on separate lines
123
456
789
When button is clicked, add a fixed string of data to each line
Textbox 2 Output:
This is my data - 123
This is my data - 456
This is my data - 789
There are an unknown number of lines in each textbox (could be 10 lines, or could be thousands of lines). The script should be able to accommodate a random number of lines as the textbox1 input will be different all the time.
My script as follows:
Private Sub Block_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Block.Click
Dim Countme As Integer
While Countme < (Textbox1.Lines.Count())
Countme = Countme + 1
Dim sb1(Textbox1.Lines.Count()) As String
sb1(Textbox1.Lines.Count()) = "This is my data" & " " & Textbox1.Text
Textbox2.Text = sb1(Textbox1.Lines.Count())
End While
End Sub
The first line seems to work correctly but subsequent lines only show the original input and not the added string data + original input in the second textbox.
Any help would be greatly appreciated.
Thanks!
Darryl
I am very new to VB Script and trying to figure out what is probably a simple issue but can't seem to get the result I want.
I have a small form I have created with 2 multiline text boxes on the left and right hand sides of the form and a couple of buttons.
When I click a button, I want to take the data from each line in one textbox, add a fixed string of data to each line of the textbox on the left, and then output the data to the right hand side textbox.
For example:
Texbox1 - Data entered on separate lines
123
456
789
When button is clicked, add a fixed string of data to each line
Textbox 2 Output:
This is my data - 123
This is my data - 456
This is my data - 789
There are an unknown number of lines in each textbox (could be 10 lines, or could be thousands of lines). The script should be able to accommodate a random number of lines as the textbox1 input will be different all the time.
My script as follows:
Private Sub Block_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Block.Click
Dim Countme As Integer
While Countme < (Textbox1.Lines.Count())
Countme = Countme + 1
Dim sb1(Textbox1.Lines.Count()) As String
sb1(Textbox1.Lines.Count()) = "This is my data" & " " & Textbox1.Text
Textbox2.Text = sb1(Textbox1.Lines.Count())
End While
End Sub
The first line seems to work correctly but subsequent lines only show the original input and not the added string data + original input in the second textbox.
Any help would be greatly appreciated.
Thanks!
Darryl