Results 1 to 5 of 5
  1. #1
    ppl2pass's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    804
    Reputation
    5
    Thanks
    111
    My Mood
    Amused

    Question [Help]random selections ComboBox

    I mean make a button and then it will randomly select and option for you.
    Last edited by ppl2pass; 03-17-2010 at 01:51 PM.

  2. #2
    MJLover's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Location
    Neverland
    Posts
    759
    Reputation
    33
    Thanks
    110
    My Mood
    Cheerful
    Quote Originally Posted by ppl2pass View Post
    I mean make a button and then it will randomly select and option for you.
    Code:
    Dim i as new random
    
    Dim x as integer= i.next (0,combobox1.items.count-1)
    
    Combobox1.selectedindex=x

  3. The Following User Says Thank You to MJLover For This Useful Post:

    ppl2pass (03-17-2010)

  4. #3
    ppl2pass's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    804
    Reputation
    5
    Thanks
    111
    My Mood
    Amused
    ok thanks. how do you make it select random options but not select a few of the options.

    ex.

    comboBox1 List:
    apples
    oranges
    pears


    random:
    selects any option but the oranges.
    so only select from pears and apples.

  5. #4
    Shark23's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Kansas
    Posts
    424
    Reputation
    10
    Thanks
    55
    My Mood
    Cool
    You could put options in an array if you wanted and have the button select an option from the array.

  6. #5
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Try this

    [php]

    Private Sub RandomCombo()

    Dim I As New Random
    Dim X As Integer = I.Next(0, ComboBox1.Items.Count - 1)

    ComboBox1.SelectedIndex = X

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    RandomCombo()

    End Sub

    Private Sub ComboBox1_SelectedItemChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    If ComboBox1.SelectedItem = "APPLES" Then
    RandomCombo()
    End If
    End Sub
    [/php]

    Essentially create a sub to call random index,
    Button press goes to sub

    on item change check if it is "Apples" , if so Re roll

    note : have not tested, using above theory and basic principles, if not, concept may need modification

    Last edited by NextGen1; 03-17-2010 at 03:09 PM.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  7. The Following 2 Users Say Thank You to NextGen1 For This Useful Post:

    MJLover (03-17-2010),ppl2pass (03-17-2010)

Similar Threads

  1. [Help]Hack Select
    By cenet1 in forum Call of Duty Modern Warfare 2 Help
    Replies: 3
    Last Post: 06-02-2010, 12:15 PM
  2. [HELP] Randomizing
    By tempta43 in forum Visual Basic Programming
    Replies: 11
    Last Post: 05-18-2010, 07:29 PM
  3. [Help]Random Color Background[Solved]
    By zmansquared in forum Visual Basic Programming
    Replies: 19
    Last Post: 03-18-2010, 03:47 AM
  4. Replies: 31
    Last Post: 09-12-2009, 08:56 PM
  5. [Help] random letter
    By noobi4life in forum Visual Basic Programming
    Replies: 4
    Last Post: 11-01-2007, 10:02 AM