Results 1 to 8 of 8

Thread: Question about text message

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    240
    I trying to do this...

    Make a program that once the user presses the command button a text message appears..and then if he presses he/she command button again, a different message appears.

    I have the user interface finished,also i have the code done for the first message that appears,but what code/else do i do??

    I appreciate any help.

  2. #2
    Guest
    Private Sub Command1_Click

    Static blnState As Boolean

    If not blnState Then
    MsgBox "Message 1"
    else
    MsgBox "Message 2"
    End If

    blnState = blnState + 1

    End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    240

    Talking

    Thank you!!

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Sascha's code switches btween message 1 and message 2 each time the command button is pressed

    if you want message 2 to be displayed for all presses >1 then set blnState to true after the first press


    I expect you worked this out for yourself anyway

    Code:
    Private Sub Command1_Click()
    
    Static blnState As Boolean
    
    If Not blnState Then
      MsgBox "Message 1"
      blnState = True
    Else
      MsgBox "Message 2"
    End If
    
    End Sub
    Mark
    -------------------

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Ok this is probably needless, but try it out
    Code:
    Private Sub Command1_Click()
    Static blnState%
    
     select case blnState
      case blnstate 1
       Msgbox "Message 1"
      case blnstate 2
       Msgbox "Message 1"
      case blnstate 3 to 5
       Msgbox "Messages for 3 to 5"
      case blnstate else
       Msgbox "Messages after that"
     end select
    
     blnState=blnState+1
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Hyperactive Member
    Join Date
    May 2000
    Location
    Kalix, Norrbotten, SWEDEN
    Posts
    343
    Dim Check as Boolean

    Private Sub Command1_Click()
    If Check = False Then
    Msgbox "Message 1"
    Check = True
    Else
    Msgbox "Message 2"
    Check = False
    End if
    End Sub

    When you click the first time, Message 1 will be shown. The second time you click Message 2 will be shown. The third time you click Message 1 will be shown, and so on....

    /Smirre

  7. #7
    Guest
    If you want to use the code in multiple CommandButtons, you can Declare it as Public or Global, in a module then use Kedaman's Code. (without the Static variable)

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    If you don't want any more answer lock this thread
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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