Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Type Mismatch

Status
Not open for further replies.

Nitrodamsel

Programmer
Mar 10, 2010
9
PH
I got an error whenever I Run my Program
Please Help me..

PUBLIC t1, t2
SET DECIMALS TO 2
SET FIXED ON
CLEAR

save=messagebox("Salary Computed!",64,"Calculation Results")
verify=1

*The content of the TEXTBOX is
*datetime(2010, 3, 11, 7, 30, 0) <-- TXTTIME
*datetime(2010, 3, 11, 17, 30, 0) <-- TXTTIMEOUT


*This computes for the Salary
t1 = thisform.pgfmain.pgsalview.txttime.value
t2 = thisform.pgfmain.pgsalview.txttimeout.value
thisform.refresh

*This returns the value of the combo box IDK
*why i got an error

*Content of Combo box cmbPosition
*200
*150
*100
*50


s = thisform.pgfmain.pgsalview.cmbPosition.value

thisform.pgfmain.pgsalview.txtdaily.value = ((t2 - t1) / 3600) * s
y = (((t2 - t1) / 3600) * s)*30

x = thisform.pgfmain.pgsalview.txtdaily.value
y = thisform.pgfmain.pgsalview.txtmonthly.value
z = thisform.pgfmain.pgsalview.txttaxes.value

thisform.pgfmain.pgsalview.txttotal.value = y - z


I GOT AN DATA ERROR MISMATCH
 
s should be m.s and that is a character value. Probably you meant:

Code:
s = val( thisform.pgfmain.pgsalview.cmbPosition.value )

Cetin Basoz
MS Foxpro MVP, MCP
 
First a suggestion rather then using variable names like x,y,z,s, use longer meaningful names (lnDaily, lnMonthly, lnTaxes)

How did you build your combo box? Does it have the * character as you've shown?

Alan
 
Yes, I agree. It's most likely that the combo box contains character values. You need to use the VAL() function to convert s to numeric.

Nitrodamsel, in general, when you get this kind of problem, a good approach is to open the debugger and use it to see what's going on. When you get the "Data type mismatch" error, click the Suspend button, then type Debug in the command window. This will bring up the debugger, which will tell you exactly which line of code producted the error. It will also tell you the values and data types of all your variables.

If you do that in this case, you will be able to confirm the data type of the s variable, and therefore immediately solve the problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top