Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Listbox to textbox


Listbox to textbox

Author
Message
luke jackson
luke jackson
Forum God
Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)

Group: Forum Members
Posts: 4, Visits: 7
I'm new to VB and new to this forum. Anyway I am wondering how you would be able to change the text of a textbox with each click of a button. I understand that using an array would probably be best, but for the sake of practice etc. I am trying to do it so that each line of text would be pulled from a list stored in a listbox. I'm assuming listbox.items.count and listbox.items(n) would be used and then you would set n+=1 or something along these lines but I can't get anything to work beyond displaying the first line of the listbox.
luke jackson
luke jackson
Forum God
Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)Forum God (1.2K reputation)

Group: Forum Members
Posts: 4, Visits: 7
Alright then. I guess this question is unanswerable.
CDRIVE
CDRIVE
Forum God
Forum God (100K reputation)Forum God (100K reputation)Forum God (100K reputation)Forum God (100K reputation)Forum God (100K reputation)Forum God (100K reputation)Forum God (100K reputation)Forum God (100K reputation)Forum God (100K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
Sure there is but I wouldn't use a CommandButton. Here's a simple example using the ListBox Click() event. Any list item clicked will be put on a new line in the textbox.

' To put each list item on its own textbox line you must first set its Multiline property to
' True at designe time in the Properties window.

Option Explicit
Dim strTxt As String
Dim i As Integer

Private Sub Form_Load()
   strTxt = "Item"
   Text1.Text = ""    ' clear the textbox
   For i = 1 To 10
      List1.AddItem strTxt & " " & i
   Next i
End Sub

Private Sub List1_Click()
   Text1.Text = Text1.Text & List1.Text & vbNewLine
End Sub



________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search