943,577 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 576
  • VB.NET RSS
Nov 7th, 2008
0

datatype mismatch error

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
onlyvidya is offline Offline
13 posts
since Sep 2008
Nov 7th, 2008
0

Re: datatype mismatch error

Click to Expand / Collapse  Quote originally posted by onlyvidya ...
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)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ksanthoshmail is offline Offline
10 posts
since Nov 2008
Nov 18th, 2008
0

Re: datatype mismatch error

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
Reputation Points: 10
Solved Threads: 9
Junior Poster
sierrainfo is offline Offline
144 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Message Box
Next Thread in VB.NET Forum Timeline: Installation help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC