Solved

trying to determine why i get a type mismatch

Posted on 2013-12-28
3
260 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:Gregory Miller
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 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…

679 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