VB problem line.

Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: VB problem line.

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    134
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have a problem line in my code, to my reckoning it should tell me I have paid no more door charges.
    The code executes but does not give me a print message.
    what is wrong with it?

    Option Explicit

    Private Sub cmdQUIT_Click()
    'Terminate Application
    End
    End Sub

    Private Sub cmdStart_Click()
    'Declare required storage
    Dim Casinos As Integer
    Dim Door_Ch As Currency
    Dim Money_Res As Currency
    Dim Cash As Currency
    Dim Money_Spent As Currency

    'ask user to input amount of cash taken out
    Cash = InputBox("Please input amount taken ", "Cash to Spend")

    Door_Ch = 1 * 6


    Casinos = Cash - Door_Ch

    'Display output in Pic box
    picMessage.Print "Door charges paid ", ""; (Door_Ch)
    picMessage.Print "Amount to spend after charges ", ""; (Cash - Door_Ch)
    picMessage.Print "In each casino he spent in casinos ", ""; (Casinos / 3)
    picMessage.Print "The amount he has left is ", ""; (Cash - 6) Mod 3
    If (Cash - 6) Mod 3 >= 2 Then
    picMessage.Print "He can visit one more Casino "
    If (Cash - 6) Mod 3 = 2 Then
    picMessage.Print "He has paid 2 more in door charges "[PROBLEM]
    ElseIf (Cash - 6) Mod 3 < 2 Then
    picMessage.Print "He pays no more door charges "[/PROBLEM]

    End If
    End If

    End Sub


    [ This Message was edited by: Charlie on 2002-10-28 08:12 ]

  2. #2
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    73,092
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Give some examples of how much cash you took and the expected reults.

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Posts
    134
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    The cash taken is user defined variable.
    The expected results are either 0 1 2 change after visting the 3 casinos 2 means he can pay 1 more door charge less than 2 means he has no more door charges to pay.
    The **** thing should work Andrew.
    Say if I take 28, I have left 1 meaning I do not pay any more door charges.
    My code should then print "No more door charges "
    Charlie

    [ This Message was edited by: Charlie on 2002-10-28 08:49 ]

  4. #4
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    73,092
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Conditions 2 and 3 will never be true because they are inside the statement:

    If (Cash - 6) Mod 3 >= 2 Then

    Your code should be:

    Code:
    If (Cash - 6) Mod 3 >= 2 Then 
       picMessage.Print "He can visit one more Casino " 
    ElseIf (Cash - 6) Mod 3 = 2 Then 
       picMessage.Print "He has paid 2 more in door charges "[PROBLEM] 
    ElseIf (Cash - 6) Mod 3 < 2 Then 
       picMessage.Print "He pays no more door charges "[/PROBLEM] 
    End If
    Remove the second End If.

  5. #5
    Board Regular
    Join Date
    Mar 2002
    Posts
    134
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thankyou Andrew,theres a pint at my local with your name on it mate

    Charlie

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

DMCA.com