Results 1 to 3 of 3

Thread: Good evening, need some help please(vb.net)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    20

    Good evening, need some help please(vb.net)

    Okay, I am basically bran new at programming, I have never programmed in any other language than vb.net, so yes, I am unexperienced.

    I am in the midst of a battleship application, you know, the game.

    I am trying to get the application (in Visual Basic.net ) to randomally place points (or ships, which are going to consist of 1 letter) behind certain points. The user will select his or her guesses buy pressing buttons (a series of 100 buttons that form the grid). So I by them pressing the button, they will press the randomly placed object, or button.

    So I don't have to just randomly place points on the entire form, but randomize locations in a given section of the form, is that possible? I have read all over msdn library and can't find anything that I can related to what I am trying to do.

    If there was a way to select all the buttons, or a universal button term, then I could easily use if-then statements, but I don't think that is going to work.

    Thanks for the help in advanced if any is given.

  2. #2
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking OK

    I'm not sure whether it's the same in VB.net as in Vb 6.0, but the best way to do this is the 'universal button term' you were talking about.
    Just set all the buttons up in an array (the easiest way to do this is either 1) call them all the same thing and click 'yes' when the it asks you whether you wnat to from an array OR 2) make one, Ctrl-C Ctrl-V and click 'yes' when it asks you whether you wnat to from an array.

    Either way, when you have the Private Sub Command1_click or whatever, it will come up with an (Index) parameter, which you can use to refer to each button individually.

    I'm sorry, you might not understand this, but just look in MSDN about arrays of objects such as buttons.
    sql_lall

  3. #3
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    VB.NET doesn't support control arrays as VB6 does, but you can do basically the same thing by having a handler for all of the buttons. I don't have .NET at work yet so I can't give you the code but take a look at the Handles keyword.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width