• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Another easy?? String Question

Problem... I want to take text from a textbox out 1 letter at a time...say to put into a list box, but I cannot find anything once again on how to do this...Is there a keyword for any character including spaces in vb?? Something like this would be fine...

Dim myString
Dim i
'X = Any and all characters in the string
myString = "XXXXXXXXXXXXXXXXXXXXX"
myString = Split(myString, "X", -1)
'Then I could add them to a listbox like:

For i = 0 To UBound(myString) - 1
List1.AddItem myString(i)
Next

This should populate the list box with single letters numbers and spaces.

The actual app will output to a Pole display, but adding to a list box is about the exact same thing.

Thanks
0
flosoft
Asked:
flosoft
  • 3
  • 2
  • 2
  • +1
1 Solution
 
vinnyd79Commented:
you could do something like this:

Private Sub Command1_Click()
Dim myString As String, mystring1 As String
Dim myString2 As String
Dim i As Integer
List1.Clear
'X = Any and all characters in the string
myString = "XXXXXXXXXXXXXXXXXXXXX"
Do Until Len(myString) = 0
mystring1 = Left$(myString, 1)
myString2 = Mid$(myString, 2)
List1.AddItem mystring1
myString = myString2
Loop

End Sub
0
 
vinnyd79Commented:
actually it can be shortened up:

Private Sub Command1_Click()
Dim myString As String
List1.Clear
'X = Any and all characters in the string
myString = "XXXXXXXXXXXXXXXXXXXXX"
Do Until Len(myString) = 0
List1.AddItem Left$(myString, 1)
myString = Mid$(myString, 2)
Loop
End Sub
0
 
DeAnCommented:
hi flosoft,

  Dim MyString As String
  MyString = "Test"
  Dim i As Integer
  For i = 1 To Len(MyString)
    MsgBox Mid(MyString, i, 1)
  Next i

hope this helps
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
DeAnCommented:
guess i should have read it more closely.

Dim MyString As String
MyString = "Test"
Dim i As Integer
For i = 1 To Len(MyString)
  List1.AddItem Mid(MyString, i, 1)
Next i
0
 
flosoftAuthor Commented:
Hey Vinny,
Thanks, worked perfect...I am pretty new to working with strings and am constantly running into issues lately with them... I also appreciate all others that answered my question!

Thanks!
0
 
supunrCommented:
what about this


Dim i as long

mySting = "XXXXXXXXXXXX"

for i = 1 to Len(myString)
    List1.AddItem Mid(myString, i, 1)
Next i

Good LUck!
0
 
supunrCommented:
DeAn, I did not copy your code. I had this page open for a while and then submitted, by the time it went through I saw your code.
0
 
DeAnCommented:
no worries supunr ;)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now