-
May 16th, 2013, 10:56 AM
#1
Thread Starter
Member
ListBox Order Selection
I have this code:
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
SendCurrentItem()
If itemIndex = ListBox1.Items.Count Then
itemIndex = 0
End If
End Sub
Private Sub SendCurrentItem()
Dim Item = ListBox1.GetItemText(ListBox1.Items(itemIndex))
SendKeys.Send(Item)
SendKeys.Send("{Enter}")
itemIndex += 1
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Timer1.Start()
End Sub
What that code does is it will take all of the items from ListBox1 and it will use SendKeys to type out each of the items every single time the timer ticks from BOTTOM to TOP.
I was wondering, how would I make it so you can choose in which order you would like the items to be typed out?
I would like the user to be able to choose if they would like the items to be typed out from BOTTOM to TOP, TOP to BOTTOM, RANDOMLY and ONLY SELECTED ITEM.
If randomly is chosen I would just like it to send out each item from the ListBox1 at random, no order.
For example, if I had 1,2,3,4 and 5 as my items it would look like this.
1
2
3
4
5
If random is selected it has the possibility to send the items like this 1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5.
Last edited by Flavor Flav; May 16th, 2013 at 11:29 AM.
-
May 16th, 2013, 11:33 AM
#2
Re: ListBox Order Selection
For top to bottom and reverse you can simply sort the items in ascending or descending order before starting your timer. For selected item don't activate your timer and just call SendCurrentItem() in the listbox selectionchanged event. For random you can use a random number generator and remove each item from the list as it is selected.
-
May 16th, 2013, 11:37 AM
#3
Re: ListBox Order Selection
If random is selected it has the possibility to send the items like this 1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5.
This is evidently some new meaning of the word random that I have not previously encountered!
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 16th, 2013, 11:39 AM
#4
Thread Starter
Member
Re: ListBox Order Selection
Originally Posted by dunfiddlin
This is evidently some new meaning of the word random that I have not previously encountered!
I am just saying that I want it to take all of the items and spit them out randomly, not in just a random order, completely random.
So instead of it going like
2
5
1
3
4
It can go like 1,1,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,5,5,5.
-
May 16th, 2013, 11:42 AM
#5
Re: ListBox Order Selection
Originally Posted by Flavor Flav
I am just saying that I want it to take all of the items and spit them out randomly, not in just a random order, completely random.
So instead of it going like
2
5
1
3
4
It can go like 1,1,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,5,5,5.
In that case the term random does not apply at all.
-
May 16th, 2013, 11:42 AM
#6
Thread Starter
Member
Re: ListBox Order Selection
Originally Posted by circuits2
In that case the term random does not apply at all.
It CAN do that...
-
May 16th, 2013, 11:45 AM
#7
Re: ListBox Order Selection
Originally Posted by Flavor Flav
It CAN do that...
Random is random. Period. Seriously, what point are you trying to make?
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
|