Solved

trying to determine why i get a type mismatch

Posted on 2013-12-28
3
255 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 74

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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