将文本转换为double [英] Converting text to double

查看:69
本文介绍了将文本转换为double的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在将文本转换为double时遇到问题。为什么代码不起作用:

如果不是(txtdocbedrag.Text ="")那么


选择案例ddlBedrag.SelectedIndex


案例0


案例1


whereSQL + =" cast(bedrag as numeric(10, 2))> " &

Double.Parse(txtdocbedrag.Text)& "''和"


案例2


whereSQL + =" cast(bedrag as numeric(10,2))> ; =''" &

Double.Parse(txtdocbedrag.Text)& "''和"


案例3


whereSQL + =" cast(bedrag as numeric(10,2))< ; " &

Double.Parse(txtdocbedrag.Text)& "''和"


案例4


whereSQL + =" cast(bedrag as numeric(10,2))< ; =''" &

Double.Parse(txtdocbedrag.Text)& "''和"


案例5


whereSQL + =" cast(bedrag as numeric(10,2))= '' " &

Double.Parse(txtdocbedrag.Text)& "''和"


案例6


whereSQL + =" cast(bedrag as numeric(10,2))> ; =''" &

Double.Parse(txtdocbedrag.Text)& "''cast(bedrag as numeric(10,2))< " &

Double.Parse(txtBedragTot.Text)& "''和"


结束选择


结束如果

解决方案



" Frederik Vanderhaeghe" < FR ****************** @ gmail.com>在消息中写道

新闻:%2 **************** @ TK2MSFTNGP02.phx.gbl ...



我在将文本转换为double时遇到问题。为什么代码不起作用:
如果不是(txtdocbedrag.Text ="")那么

选择案例ddlBedrag.SelectedIndex

案例0 <情况1

whereSQL + =" cast(bedrag as numeric(10,2))> " &
Double.Parse(txtdocbedrag.Text)& &和

案例2


< cast(bedrag as numeric(10,2))> =''" &
Double.Parse(txtdocbedrag.Text)& &和

案例3
whereSQL + =" cast(bedrag as numeric(10,2))< " &
Double.Parse(txtdocbedrag.Text)& &和

案例4


< cast(bedrag as numeric(10,2))< =''" &
Double.Parse(txtdocbedrag.Text)& &和

案例5


其中SQL + =" cast(bedrag as numeric(10,2))=''" &
Double.Parse(txtdocbedrag.Text)& &和

案例6


< cast(bedrag as numeric(10,2))> =''" &
Double.Parse(txtdocbedrag.Text)& "''cast(bedrag as numeric(10,2))< " &
Double.Parse(txtBedragTot.Text)& &和

结束选择

结束如果



我发现的一件事就是使用单引号标点符号围绕数字

值(Double.Parse(...)的结果。

在你的SQL查询中(这就是你正在构建的) ,更正?),数值

应该没有围绕它们的标点字符。字符串值需要

单引号,关于日期(在SQL Server中。访问日期标点符号是

#。)。


-

彼得[MVP视觉开发者]

杰克所有行业,无人掌握。


我不知道但是将字符串转换为双字母确实有效:

Dim st As String =" 2.0"

Dim d As Double

d = Double.Parse(st)

" Frederik Vanderhaeghe" fr **** **************@gmail.com>在留言中写道

新闻:%2 **************** @ TK2MSFTNGP02.phx.gbl ...



我在将文本转换为double时遇到问题。为什么代码不起作用:
如果不是(txtdocbedrag.Text ="")那么

选择案例ddlBedrag.SelectedIndex

案例0 <情况1

whereSQL + =" cast(bedrag as numeric(10,2))> " &
Double.Parse(txtdocbedrag.Text)& &和

案例2


< cast(bedrag as numeric(10,2))> =''" &
Double.Parse(txtdocbedrag.Text)& &和

案例3
whereSQL + =" cast(bedrag as numeric(10,2))< " &
Double.Parse(txtdocbedrag.Text)& &和

案例4


< cast(bedrag as numeric(10,2))< =''" &
Double.Parse(txtdocbedrag.Text)& &和

案例5


其中SQL + =" cast(bedrag as numeric(10,2))=''" &
Double.Parse(txtdocbedrag.Text)& &和

案例6


< cast(bedrag as numeric(10,2))> =''" &
Double.Parse(txtdocbedrag.Text)& "''cast(bedrag as numeric(10,2))< " &
Double.Parse(txtBedragTot.Text)& "''和"

结束选择

结束如果



但问题是cast(bedrag as numeric(10,2)

bedrag = databasefield

" Pipo"< Pa **** @ Mayo.com>在消息中写道

news:OR ************** @ TK2MSFTNGP02.phx.gbl ...

I不知道但是将字符串转换为双字母确实有效:
Dim st As String =" 2.0"
Dim d As Double
d = Double.Parse(st)

Frederik Vanderhaeghe< fr ****************** @ gmail.com>在留言中写道
新闻:%2 **** ************ @ TK2MSFTNGP02.phx.gbl ...



我在将文本转换为double时遇到问题。为什么代码不起作用:
如果不是(txtdocbedrag.Text ="")那么

选择案例ddlBedrag.SelectedIndex

案例0
whereSQL + =" cast(bedrag as numeric(10,2 ))>''" &
Double.Parse(txtdocbedrag.Text)& &和

案例2


< cast(bedrag as numeric(10,2))> =''" &
Double.Parse(txtdocbedrag.Text)& &和

案例3
whereSQL + =" cast(bedrag as numeric(10,2))< " &
Double.Parse(txtdocbedrag.Text)& &和

案例4


< cast(bedrag as numeric(10,2))< =''" &
Double.Parse(txtdocbedrag.Text)& &和

案例5


其中SQL + =" cast(bedrag as numeric(10,2))=''" &
Double.Parse(txtdocbedrag.Text)& &和

案例6


< cast(bedrag as numeric(10,2))> =''" &
Double.Parse(txtdocbedrag.Text)& "''cast(bedrag as numeric(10,2))< " &
Double.Parse(txtBedragTot.Text)& 结束选择

结束如果




Hi,

I have a problem converting text to a double. Why doesn''t the code work:
If Not (txtdocbedrag.Text = "") Then

Select Case ddlBedrag.SelectedIndex

Case 0

Case 1

whereSQL += "cast(bedrag as numeric(10,2)) > ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 2

whereSQL += "cast(bedrag as numeric(10,2)) >= ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 3

whereSQL += "cast(bedrag as numeric(10,2)) < ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 4

whereSQL += "cast(bedrag as numeric(10,2)) <= ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 5

whereSQL += "cast(bedrag as numeric(10,2)) = ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 6

whereSQL += "cast(bedrag as numeric(10,2)) >= ''" &
Double.Parse(txtdocbedrag.Text) & "'' cast(bedrag as numeric(10,2)) < ''" &
Double.Parse(txtBedragTot.Text) & "'' and "

End Select

End If

解决方案


"Frederik Vanderhaeghe" <fr******************@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...

Hi,

I have a problem converting text to a double. Why doesn''t the code work:
If Not (txtdocbedrag.Text = "") Then

Select Case ddlBedrag.SelectedIndex

Case 0

Case 1

whereSQL += "cast(bedrag as numeric(10,2)) > ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 2

whereSQL += "cast(bedrag as numeric(10,2)) >= ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 3

whereSQL += "cast(bedrag as numeric(10,2)) < ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 4

whereSQL += "cast(bedrag as numeric(10,2)) <= ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 5

whereSQL += "cast(bedrag as numeric(10,2)) = ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 6

whereSQL += "cast(bedrag as numeric(10,2)) >= ''" &
Double.Parse(txtdocbedrag.Text) & "'' cast(bedrag as numeric(10,2)) < ''" &
Double.Parse(txtBedragTot.Text) & "'' and "

End Select

End If


One thing I spotted is the use of single quote punctuation around a numeric
value (the result of Double.Parse(...).
In your SQL query (that is what you''re building, correct?), numeric values
should have no punctuation characters surrounding them. String values need
single quotes, as to dates (in SQL Server. Access date punctuation is the
#.).

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.


I dont know but converting a string to a double does work:
Dim st As String = "2.0"
Dim d As Double
d = Double.Parse(st)
"Frederik Vanderhaeghe" <fr******************@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...

Hi,

I have a problem converting text to a double. Why doesn''t the code work:
If Not (txtdocbedrag.Text = "") Then

Select Case ddlBedrag.SelectedIndex

Case 0

Case 1

whereSQL += "cast(bedrag as numeric(10,2)) > ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 2

whereSQL += "cast(bedrag as numeric(10,2)) >= ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 3

whereSQL += "cast(bedrag as numeric(10,2)) < ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 4

whereSQL += "cast(bedrag as numeric(10,2)) <= ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 5

whereSQL += "cast(bedrag as numeric(10,2)) = ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 6

whereSQL += "cast(bedrag as numeric(10,2)) >= ''" &
Double.Parse(txtdocbedrag.Text) & "'' cast(bedrag as numeric(10,2)) < ''" &
Double.Parse(txtBedragTot.Text) & "'' and "

End Select

End If



but the problem is the "cast(bedrag as numeric(10,2)"
bedrag=databasefield
"Pipo" <Pa****@Mayo.com> wrote in message
news:OR**************@TK2MSFTNGP02.phx.gbl...

I dont know but converting a string to a double does work:
Dim st As String = "2.0"
Dim d As Double
d = Double.Parse(st)
"Frederik Vanderhaeghe" <fr******************@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...

Hi,

I have a problem converting text to a double. Why doesn''t the code work:
If Not (txtdocbedrag.Text = "") Then

Select Case ddlBedrag.SelectedIndex

Case 0

Case 1

whereSQL += "cast(bedrag as numeric(10,2)) > ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 2

whereSQL += "cast(bedrag as numeric(10,2)) >= ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 3

whereSQL += "cast(bedrag as numeric(10,2)) < ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 4

whereSQL += "cast(bedrag as numeric(10,2)) <= ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 5

whereSQL += "cast(bedrag as numeric(10,2)) = ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 6

whereSQL += "cast(bedrag as numeric(10,2)) >= ''" &
Double.Parse(txtdocbedrag.Text) & "'' cast(bedrag as numeric(10,2)) < ''" &
Double.Parse(txtBedragTot.Text) & "'' and "

End Select

End If




这篇关于将文本转换为double的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆