CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 35 of 35
  1. #31
    Join Date
    Sep 2009
    Posts
    126

    Re: Save game/Load game

    Quote Originally Posted by dglienna View Post
    You can Shell() a program to open it.
    Code:
    Shell("C:\temp\notepad.exe")
    ok thanx
    Now I have made my game, but I have made an code system. For example you can buy with real money some money to the game.
    Here is the code:
    If Text1.Text = 489331 Then
    Label1 = Val(Label1) + 5000
    Else
    If Text1.Text = 123456 Then
    Label1 = Val(Label1) + 500000
    Else
    MsgBox "Wrong code"
    End If
    End If
    But I need to get it so that you only can use the code 489331 once. Otherwise you can press the "Submit" button 100000000 times and get a lot of money.
    Anyone?

  2. #32
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Save game/Load game

    Use a FLAG, initialize it somewhere else

    Code:
    Dim Flag1 as Boolean 
    Flag1=False

    Code:
    if Flag1=false then
      If Text1.Text = 489331 Then
        Flag1=True
        Label1 = Val(Label1) + 5000
      End If
    End If
    this will only fire the first time. that's how you use a flag
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #33
    Join Date
    Sep 2009
    Posts
    126

    Re: Save game/Load game

    Quote Originally Posted by dglienna View Post
    Use a FLAG, initialize it somewhere else

    Code:
    Dim Flag1 as Boolean 
    Flag1=False

    Code:
    if Flag1=false then
      If Text1.Text = 489331 Then
        Flag1=True
        Label1 = Val(Label1) + 5000
      End If
    End If
    this will only fire the first time. that's how you use a flag
    Dosen't work.
    I can press the "Submit" button how many times I whant ansd there is still coming money

  4. #34
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Save game/Load game

    Not quite right:

    Code:
    Flag1=False
    
    Sub ...
    Static Flag1 as Boolean ' stays the same, starts at false
    if Flag1=false then
      If Text1.Text = 489331 Then
        Flag1=True
        Label1 = Val(Label1) + 5000
      End If
    End If
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #35
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Save game/Load game

    This is not as trivial as you might think.
    If you restart the program the flag is reset again. You can repeatedly start the program and press the submit button once again.

    There must be a more complex mechanism to make sure, a code is only used once, if you want to be sure.

Page 3 of 3 FirstFirst 123

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

Featured