Solved

Problem with a function

Posted on 2014-04-15
13
156 Views
Last Modified: 2014-04-15
This is a Keno game
Clicking the lblcredit switches between Currency and credit display based on the the bet mode
5 Bet modes:
1 cent
2 cent
5 cents
10 cents
25 cents.

try as might i cannot get it to display correctly.
Example how it should work:
1 cent mode:
credit displays $1.00 clicking the lblcredit displays 100
clicking again displays $1.00 again

2 cent mode
credit displays $1.00 clicking the lblcredit displays 50
clicking again displays $1.00 again


5 cent mode
credit displays $1.00 clicking the lblcredit displays 20
clicking again displays $1.00 again

10 cent mode
credit displays $1.00 clicking the lblcredit displays 10
clicking again displays $1.00 again

25 cent mode
credit displays $1.00 clicking the lblcredit displays 4
clicking again displays $1.00 again

Clicking the cmdbetmode cycles the bet mode
see attached small project
What am i doing wrong ?Testing-BetMode-change.zip
0
Comment
Question by:isnoend2001
  • 7
  • 6
13 Comments
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
I'll take a look at it.
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
What is the difference between Currency and credit display?
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
And what do you want to see when bet mode is 1 cent and you click lblcredit?
0
 

Author Comment

by:isnoend2001
Comment Utility
example;
5 Cent mode
Currency: $1.00
Credit: 20( eg;.05 x .20 = $1.00
0
 

Author Comment

by:isnoend2001
Comment Utility
And what do you want to see when bet mode is 1 cent and you click lblcredit?
If display Is currency Then clicking  lblCredit changes the display to credits
This is how it works at the casinos
0
 

Author Comment

by:isnoend2001
Comment Utility
Clicking lblCredit toggles between credit & currency based on the bet mode
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
Sorry but I still don't understand. In 5 cent mode and lblCredit = $1.00 what should lblCredit change to when it's clicked? What should it be when it's clicked again?
0
 

Author Comment

by:isnoend2001
Comment Utility
How it works at the casino:
Put a dollar in a slot machine lblCredit reads $1.00 if in currency mode
In 5 cent mode clicking lblCredit displays changes to credit= 20  (20 nickles = $1.00)
The value does not change
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
Well with a dollar credit in 5-cent mode clicking lblCredit toggles between "$1.00" and "20", and in 1-cent mode it toggles between "$1.00" and "100". Aren't both of those correct?
0
 

Author Comment

by:isnoend2001
Comment Utility
yes both are correct its when i change to other modes like 5 cents
displays $2.50 instead of $1.00.
they should display as follows:
1 cent = $1.00 and 100
2 cent =$1.00 and 50
5 cent=$1.00 and 20
10 cent =$1.00 and 10
25 cent=$1.00 and 4
0
 

Author Comment

by:isnoend2001
Comment Utility
seems that clicking between cmdbetmode and lblcredit the results mostly are correct, but sometimes not
0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
Comment Utility
Try this.

Option Explicit
Dim mintBetMode As Integer
Dim mintCreditMode As Integer
'new
'Dim gcurCleoNewGameCredits As String
Dim gcurCleoNewGameCredits As Currency


Private Sub cmdbetmode_Click()
ChangeBetMode
End Sub

Private Sub Form_Load()
'new
'gcurCleoNewGameCredits = "$1.00"
gcurCleoNewGameCredits = 1

lblCredit = Format(gcurCleoNewGameCredits, "currency")
End Sub
Private Function DetermineCredits()
'new
'Dim credit As String
'credit = lblCredit
'DetermineCredits = credit / GetPriceByBetMode(mintBetMode)
DetermineCredits = gcurCleoNewGameCredits / GetPriceByBetMode(mintBetMode)
End Function
'change credits to currency
Private Function DetermineCurrency(ByVal credit As String, ByVal BetMode As Integer)
  DetermineCurrency = Val(credit) * GetPriceByBetMode(BetMode)
End Function
Private Function GetPriceByBetMode(ByVal BetMode As Integer) As Double
    Select Case BetMode
        Case 0
           GetPriceByBetMode = 0.01
        Case 1
           GetPriceByBetMode = 0.02
        Case 2
           GetPriceByBetMode = 0.05
        Case 3
           GetPriceByBetMode = 0.1
        Case 4
           GetPriceByBetMode = 0.25
    End Select
    
End Function
Sub ChangeBetMode()
      Dim oldBetMode As Integer
      oldBetMode = mintBetMode
  
      If mintBetMode = 4 Then
         mintBetMode = 0
       Else
         mintBetMode = mintBetMode + 1
      End If
   
   'new - It's more efficient to use Select Case then ElseIfs
'        If mintBetMode = 0 Then
'           cmdbetmode.Caption = "1 Cents"
'
'        ElseIf mintBetMode = 1 Then
'        cmdbetmode.Caption = "2 Cents"
'
'        ElseIf mintBetMode = 2 Then
'            cmdbetmode.Caption = "5 Cents"
'
'         ElseIf mintBetMode = 3 Then
'          cmdbetmode.Caption = "10 Cents"
'        Else
'          cmdbetmode.Caption = "25 Cents"
'        End If
    Select Case mintBetMode
        Case 0
            cmdbetmode.Caption = "1 Cent" ' Note: Not cents
        Case 1
            cmdbetmode.Caption = "2 Cents"
        Case 2
            cmdbetmode.Caption = "5 Cents"
        Case 3
            cmdbetmode.Caption = "10 Cents"
        Case Else
            cmdbetmode.Caption = "25 Cents"
    End Select
           
End Sub

Private Sub lblCredit_Click()
If InStr(lblCredit, "$") Then ' change to credit
    'change to credits
     lblCredit = DetermineCredits
     mintCreditMode = 0
  Else
  'new
'  lblCredit = DetermineCurrency(lblCredit, mintBetMode)
  lblCredit = gcurCleoNewGameCredits

lblCredit = Format(lblCredit, "currency")
mintCreditMode = 1
  End If
End Sub

Open in new window

0
 

Author Closing Comment

by:isnoend2001
Comment Utility
thanks martinliss for the help again
I have not tried yet,but what if the start is not currency
I have an ini file that loads the credit or currency that the user used last:
giCleoCreditOrCurrency
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now