Need help with simple project
ok guys i need some help i am trying to make a listbox load whats in the textbox but i want it to repeat the text after its added so like say if i have ! in the text box it would add this to the listbox
!
!!
!!!
!!!!
!!!!!
!!!!!!
!!!!!!!
and so on
any help would be greatful
Re: Need help with simple project
you can try like
vb Code:
for i = 1 to x
mystr = mystr & text1
list1.additem mystr
next
where x is the number of items you want to add to listbox
for a single character you can use
list1.additem string(i, text1)
in place of building a string
Re: Need help with simple project
Hello,
There is a built-in VB6 function for this : String$(number as Long, Character) as String
Example :
You should have a command button (command1), a listbox (list1) and a textbox (text1)
vb Code:
Private Sub Command1_Click()
Dim str As String
Dim i As Integer
i = 0
'The length of the text in the textbox should be only one char
str = Text1.Text
Do Until i = 7 ' This will be the number of items in
'the list. You may change it for more results
i = i + 1
List1.AddItem String$(i, str)
Loop
End Sub
However, the String$ function only repeats one character. That means that the textbox's text should be only one char. And if it's not, the String$ function will repeat only the first character in it.