|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Ok im basically trying to get it same that i can copy information from a list box to text box same that i can save the informaton in a .txt file. and since i cant work out how the hell to get the information to save from a list box iv come up with this only problem is i cant get all of the list to copy across i only get the 1st one selected.
Code:
Private Sub Command1_Click() Dim i As Integer If List1.ListIndex = -1 Then Exit Sub For i = List1.ListCount - 1 To 0 Step -1 If List1.Selected(i) = True Then Text1.Text = List1.list(i) List1.RemoveItem i End If Next i End Sub Private Sub Form_Load() With List1 .AddItem "1" .AddItem "2" .AddItem "3" .AddItem "4" End With End Sub im unsure what is wrong as im only a beginner at this so if anyone can help me with this code or tell me how to save information from list boxes to .txt file would be gratful |
|
#2
|
|||
|
|||
|
Private Sub Command1_Click()
Dim i As Integer If List1.ListIndex = -1 Then Exit Sub For i = List1.ListCount - 1 To 0 Step -1 If List1.Selected(i) = True Then Text1.Text = List1.list(i) <----- THIS IS THE ERROR !!! List1.RemoveItem i End If Next i The error line replaces the text of the textbox in every attempt of the loop..... replace the line with Text1.Text = Text1 & " " & List1.Text and ur job is done |
|
#3
|
|||
|
|||
|
not exactly what i wanted but it closer i want the text to be transered so it is displayed in the text box as it was in the list box not all on same line but thanx anyway
|
|
#4
|
|||
|
|||
|
Set txtfile = fso.CreateTextFile(Path of your file here, True)
txtfile.WriteLine (Your variable here) txtfile.Write (Your variable here) txtfile.Close What I would do is create a string variable to capture the list box, your loop should populate the string variable then place the variable in the code above, Note: WritLine creates the line then returns a new line, where write just writes the line with no return. Also note you will need this in the general declaration section of you project. Dim fso As New FileSystemObject Hope this helps Journeyman |
|
#5
|
|||
|
|||
|
Quote:
well for that set multiline for the textbox = True in properties and replace the line (Text1.Text = Text1 & " " & List1.Text) with Text1.Text = Text1 & " " & vbCrlf & List1.Text |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Trying to copy contents of list box into textbox |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|