|
-
Jun 25th, 2010, 01:18 AM
#1
Thread Starter
Lively Member
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
If i help please rate me
If Your Question Has Been Answered Please Mark Your Thread As RESOLVED So Other People (ME) Can Use The Helpful Tips As Well , Thanks
New to VBForums? It's ok i was also at one point n time and i am still learning and meeting new people everyday check out the FAQ Section it is very helpful
Sleep brings release and the hope of a new day - Killswitch Engage
-
Jun 25th, 2010, 04:39 AM
#2
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 25th, 2010, 04:53 AM
#3
Lively Member
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.
MOBO: Asrock X58 Extreme
CPU : Core i7 950 @ 3.07Ghz
Ram : 8GB
Hard Drive : 1.5 TB (1 TB, 500GB)
Graphics : ATI Radeon HD 5670
Dual Boot : Windows XP Home, Windows 7 Ultimate x64
       
_____________________
If a reply has helped you, please consider rating it. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|