Solved

trying to determine why i get a type mismatch

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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 …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

737 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