# Problem with a function

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
###### Who is Participating?

Older than dirtCommented:
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

'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
``````
0

Older than dirtCommented:
I'll take a look at it.
0

Older than dirtCommented:
What is the difference between Currency and credit display?
0

Older than dirtCommented:
And what do you want to see when bet mode is 1 cent and you click lblcredit?
0

Author Commented:
example;
5 Cent mode
Currency: \$1.00
Credit: 20( eg;.05 x .20 = \$1.00
0

Author Commented:
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 Commented:
Clicking lblCredit toggles between credit & currency based on the bet mode
0

Older than dirtCommented:
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 Commented:
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

Older than dirtCommented:
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 Commented:
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 Commented:
seems that clicking between cmdbetmode and lblcredit the results mostly are correct, but sometimes not
0

Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.