954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

datatype mismatch error

Hi frnds,,
i hv a form in which i want to calculate balance.I wrote code for this as follows.
But its giving me an error as "Datatype mismatch error". I hv declared bal & amt in database as Currency.Is this proper??If not suggest me some other code plzzzz.
what datatype should I specify for these two variables??
Dim bal, amt As Integer
If (cmbtrans.SelectedItem = "DEPOSIT") Then
bal = 0
amt = Val(txtamt.Text)
bal = bal + amt
txtbalance.Text = bal

End If

onlyvidya
Newbie Poster
13 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

Hi frnds,, i hv a form in which i want to calculate balance.I wrote code for this as follows. But its giving me an error as "Datatype mismatch error". I hv declared bal & amt in database as Currency.Is this proper??If not suggest me some other code plzzzz. what datatype should I specify for these two variables?? Dim bal, amt As Integer If (cmbtrans.SelectedItem = "DEPOSIT") Then bal = 0 amt = Val(txtamt.Text) bal = bal + amt txtbalance.Text = bal

End If


re:
Better You can Use Double
i.e
Dim bal, amt as Double

Because amount are having decimal values.
like 0.00

and also change database Datatype to money or float(in sqlserver2000)

ksanthoshmail
Newbie Poster
10 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

You can Use Double

Dim bal, amt as Double ' like 0.00

If you are using MS Access Database not need to change Currency Datatype
or using SQL Server 2000 in database change Datatype to money or float.

Regards

sierrainfo
Junior Poster
144 posts since May 2008
Reputation Points: 10
Solved Threads: 9
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You