|
-
April 3rd, 2012, 01:21 PM
#4
Re: Visual Basic 2010 Express - Need Help Passing Data from CheckedListBox to TextBox
I now have the code working to send all of the checked items in checkbox1 on form2 to textbox1 on form1. Which I wanted to get working before I moved on to try to learn how to now just get 5 of the numbers randomly from those selected on the checkedlistbox (i.e. If the user selects 20 numbers on the checkedlistbox on form2 and hits submit, the program will take 5 of those 20 selected randomly and return them to the textbox on form1). Here is how I have done that:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim NumberSelect As Form2
Private Property CheckedListBox1 As Form2
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Using dialogue As New Form2
dialogue.ShowDialog()
Me.TextBox1.Text = dialogue.TextBoxText
End Using
End Sub
End Class
Public Class Form2
Public Property TextBoxText() As String
Get
Return Me.TextBox3.Text
End Get
Set(value As String)
Me.TextBox3.Text = value
End Set
End Property
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Randomize()
Dim i As Integer = 0
' Loop through all the selected items of the listbox and append them to the textbox text property
For i = 0 To CheckedListBox1.CheckedItems.Count - 1
TextBox3.Text &= CheckedListBox1.CheckedItems.Item(i).ToString() & " "
Next
End Sub
End Class
----------------
I have a little more knowledge of the Random() command, but still am lost in how to incorporate it to do what I am trying to do.
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
|