Solved

trying to determine why i get a type mismatch

Posted on 2013-12-28
3
267 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
[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
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 Month2 days, 18 hours left to enroll

621 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