?
Solved

Another easy?? String Question

Posted on 2003-03-06
8
Medium Priority
?
164 Views
Last Modified: 2010-04-07
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
Comment
Question by:flosoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 8084751
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
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 100 total points
ID: 8084773
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
 
LVL 3

Expert Comment

by:DeAn
ID: 8084779
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Expert Comment

by:DeAn
ID: 8084787
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
 

Author Comment

by:flosoft
ID: 8084795
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
 
LVL 11

Expert Comment

by:supunr
ID: 8084846
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
 
LVL 11

Expert Comment

by:supunr
ID: 8084858
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
 
LVL 3

Expert Comment

by:DeAn
ID: 8084882
no worries supunr ;)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question