Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

Problem with a function

Posted on 2014-04-15
Medium Priority
171 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
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• Learn & ask questions
• 7
• 6
13 Comments

LVL 49

Expert Comment

ID: 40002891
I'll take a look at it.
0

LVL 49

Expert Comment

ID: 40002901
What is the difference between Currency and credit display?
0

LVL 49

Expert Comment

ID: 40002905
And what do you want to see when bet mode is 1 cent and you click lblcredit?
0

Author Comment

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

Author Comment

ID: 40002909
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

ID: 40002912
Clicking lblCredit toggles between credit & currency based on the bet mode
0

LVL 49

Expert Comment

ID: 40002917
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

ID: 40002926
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 49

Expert Comment

ID: 40002992
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

ID: 40003036
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

ID: 40003049
seems that clicking between cmdbetmode and lblcredit the results mostly are correct, but sometimes not
0

LVL 49

Accepted Solution

Martin Liss earned 2000 total points
ID: 40003094
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
``````
0

Author Closing Comment

ID: 40003114
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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for â€˜enumerationsâ€™) are not often used by programmers but they can be quite valuable when they are. Â What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that containsâ€¦
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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â€¦
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that aâ€¦
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

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

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