VB中text里面的数据怎么读出
文本框里面比如随便输入,用逗号隔开的数字2,43,53,0.54,5.7,34,-43,-4,等,怎样读取其中的例如53和5.7,点击按钮然后相加或者别得用途。抱歉了没积...
文本框里面比如 随便输入,用逗号隔开的数字 2,43,53,0.54,5.7,34,-43,-4,等,怎样读取其中的例如53和5.7,点击按钮 然后相加或者别得用途。 抱歉了没积分
展开
2个回答
展开全部
假定文本框是Text1
Dim s() As String, i As Integer, N As Double
s = Split(Text1.Text, ",")
For i = 0 To UBound(s)
Print "第"; i + 1; "个数是"; s(i)
N = N + Val(s(i))
Next
Print "数字的和是"; N
注意,数字间的分隔符要用半角的逗号,不要用全角的。
Dim s() As String, i As Integer, N As Double
s = Split(Text1.Text, ",")
For i = 0 To UBound(s)
Print "第"; i + 1; "个数是"; s(i)
N = N + Val(s(i))
Next
Print "数字的和是"; N
注意,数字间的分隔符要用半角的逗号,不要用全角的。
更多追问追答
追问
追答
TEM = Split(Text4.Text, ",")
改为
TEM = Split(Text4.Text, IIf(InStr(Text4.Text, ","), ",", vbCrLf))
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询