| |

VerySource

 Forgot password?
 Register
Search
View: 27|Reply: 9

How to convert data entered in textbox to money type in vb + sql server

[Copy link]

2

Threads

3

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 China

Post time: 2020-2-8 12:30:01
| Show all posts |Read mode
How to convert data entered in textbox to money type in vb + sql server
Reply

Use magic Report

0

Threads

3

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 Netherlands

Post time: 2020-4-1 21:15:01
| Show all posts
cdbl (text1.text)
Reply

Use magic Report

0

Threads

2

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 China

Post time: 2020-4-2 11:45:01
| Show all posts
text1.text = Format (text1.text, "## 0.00")
Reply

Use magic Report

0

Threads

4

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 China

Post time: 2020-4-2 18:45:01
| Show all posts
Format (text1.text, "#, ## 0.00")
Reply

Use magic Report

2

Threads

3

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 China

 Author| Post time: 2020-5-29 23:00:01
| Show all posts
Boss: No, report an error
Real-time error '-2147217913 (80040e07)'
Invisible conversion from data type varchar to data type money (.......) is not allowed, please use the convert function to run this query
Reply

Use magic Report

1

Threads

10

Posts

10

Credits

Newbie

Rank: 1

Credits
10

 China

Post time: 2020-6-3 10:30:01
| Show all posts
First of all, you must make sure that the string entered in your text box can be converted into a value normally, and then directly substituted into the SQL statement according to the string.No conversion is required. When substituting, you can consider the following method:
drs.open "select * from table name where MoneyField="+cstr(val(text1.text)), yourcn

After two data conversions under VB, it is to convert the content in the text box into a string that can indeed be interpreted by SQL as Money
Reply

Use magic Report

1

Threads

10

Posts

10

Credits

Newbie

Rank: 1

Credits
10

 China

Post time: 2020-6-5 23:30:01
| Show all posts
mcn.execute "insert into table name (Number,Name,Money) values ​​('00001','"+me.txtName.text+"',"+cstr(val(me.txtMoney.text))+")"
Reply

Use magic Report

0

Threads

2

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

Post time: 2020-6-7 00:15:01
| Show all posts
dim dec_Money as decimal=0
dec_Money=Cdec(trim$(txtMoney.text))
Reply

Use magic Report

0

Threads

6

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 China

Post time: 2020-7-4 14:30:01
| Show all posts
First check whether it can be converted to a numeric type and then convert it. Maybe it is a null value and cannot be converted
if isnumeric(text1) then
....
end if
Reply

Use magic Report

0

Threads

9

Posts

5

Credits

Newbie

Rank: 1

Credits
5

 China

Post time: 2020-7-4 20:30:01
| Show all posts
Convert the value first to format the money.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list