Tag Archives: String

You learn something new every day

I didn’t know that Visual Basic Express Edition could handle a string as an Array. Some programming languages require you to use individual characters and then create an array of these to create a string, so I guess that is what is going on. I also found this article on spiting and joining arrays.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim UserString As String
Getstring(UserString)
DisplayString(UserString)
End Sub
Private Sub GetString(ByRef UserString As String)
UserString = InputBox(“What is your name”)
End Sub
Private Sub DisplayString(ByVal UserString As String)
For Counter = 0 To (Len(UserString) – 1)
ListBox1.Items.Add(UserString(Counter))
Next
End Sub
So for the string “John” we get the following
VB5CCE does not do this, we get the following error