Results 1 to 4 of 4

Thread: Sort of a Game - New Problem

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2006
    Posts
    35

    Sort of a Game - New Problem

    Ok, I'm learning visual basic, and I have to say that the MSDN never seems to have exactly what I need. I'm doing the typical "Guessing Game". The main part of it I can do, as I've already done it in Liberty Basic, but as in the title Visual Basic is "Visual". Enough ado, I am trying to make a label display for each attempt (max. of ten). Now I can do:

    If attempt = 1 then
    lblGuess1.Caption = "Guess 1: " & Guess & "." & HighLow
    Else If attempt = 2 then
    lblGuess2.Capion = "Guess 2: " & Guess & "." & HighLow
    Else if... etc. etc.

    where HighLow is a string that displays if the guessed number is too high or too low or correct.

    But doing that way would take too much time, so i want to know if there is a way to make so that the Label, lblGuess, be the label that matches the value of Attempt.

    Something like:

    lblGuess & attempt.caption = "Guess " & Attempt & ": " & Guess & "." & HighLow.

    Is that possible? I know the code I've written doesn't work but is there a way to do what I'm trying to do?

    Edit: The previous problem was resolved, but now I have a new one. I really should get my hands on the VB Manual (If there is one).

    This is my problem now, and it's quite a simple one; when I make an Input Box when the form loads I need to know how to make the cancel button end the form. A Variable called UserName is value of the Input Box.
    UserName = InputBox("Hello. Please enter your name before playing.", "Name?", "Name")
    Last edited by Prodian; Apr 27th, 2006 at 04:56 PM. Reason: New Problem

  2. #2
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Re: Sort of a Game

    ok you can set up a control array... to do this take one label on the form copy and paste it, it will ask if you want to make a control array, click yes... then - the labels will be called "lblGuess(0), lblGuess(1), lblGuess(2)"... and so on, so you could do...

    lblGuess & "(" & Attempt & ")" = "Guess " & Attempt & ": " & Guess & "." & HighLow.
    Software languages known:
    Qbasic - TI-Basic - Liberty Basic - Visual Basic 6
    Software API's known:
    Directx 7 and 8
    Internet languages, in the process of learning:
    HTML - JAVASCRIPT - PHP - CSS - MYSQL - AJAX

  3. #3
    Android OpenGL ES Guru Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,278

    Re: Sort of a Game

    MSDN sucks to be honest with you, even as a reference. It's best to stick with other sites, like VBForums (check the Game Demos and Code Bank), Planet Source Code, GameDev.net, etc. Plenty of gaming and programming tutorials out there.

  4. #4

    Thread Starter
    Member
    Join Date
    Apr 2006
    Posts
    35

    Re: Sort of a Game

    Thanks guys, you've been a great help.

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