Solved

trying to determine why i get a type mismatch

Posted on 2013-12-28
3
256 Views
Last Modified: 2013-12-28
betmode is either 0 or 1
1= currency
0= credits



Private Function CreditMode0String(ByVal credit As String, ByVal betMode As Integer)
    credit = IIf(InStr(credit, "$") > 0, CCur(Mid(credit, 2)), CCur(credit)) highlighted line
    'credit = CCur(Mid(credit, 2))
    CreditMode0String = credit / GetPriceByBetMode(betMode)
End Function

why am i getting this error ?
0
Comment
Question by:isnoend2001
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39743741
My guess--since I don't have old-skool VB to play with--would be that you are assigning a currency instance to a string variable. Have you tried doing the conversion without the call to Mid?

e.g.

Private Function CreditMode0String(ByVal credit As String, ByVal betMode As Integer)
    CreditMode0String = CCur(credit) / GetPriceByBetMode(betMode)
End Function

Open in new window

0
 
LVL 11

Expert Comment

by:Technodweeb
ID: 39743749
@kaufmed is probably right on target. I would add that if the variable credit is a numeric value that is used in many mathematical functions, you should store it as a single or double type so you do not have to test for the presence of the $ character every time. Any time you want to display the value of the credit variable, you can always use formatting to slap that $ symbol back on and add commas in proper positions if desired.
0
 

Author Closing Comment

by:isnoend2001
ID: 39743789
Thanks I gave mBetMode a value of 1 and now it works.
the program runs in different price denomitions eg;1cent,2cent, 5cent, 10 cent, 25cent
and can be displayed as currency or credits
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

914 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

19 Experts available now in Live!

Get 1:1 Help Now