Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2010 ListBox Order Selection

$
0
0
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.

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>