逗号vb.net 逗号表达式

vb.net如何判断一个字段有几个逗号Dim s As String
Dim n As Integer
Dim L As Integer
s = "a,b,vfg,cdf,as,as,as,as,\/,"
n = 0
L = InStr(1, s, ",")
Do While L0
n = n1
L = InStr(L1, s, ",")
Loop
MsgBox n
VB.NET错误提醒中应为逗号,“)”或有效的表达式继续符什么意思?VB.NET 语句结束不需要加;(分号)
"integrated security=SSPI;")你这是连接数据库吗?
vb.net用文本框输入数组的所有元素,数值之间用逗号分隔,统计数组中正数的个数,并显示最大值的元素下标Dim str As String = "", temp, n As Integer
Dim str1 As String = "12,45,2,9,41,31,66,83,2,1,-9,-91,-21"
Dim a() As String = Split(str1, ",")
For i = 1 To UBound(a) Step 1
a(i) = Val(a(i))
【逗号vb.net 逗号表达式】Next
temp = 0
n = 0
For i = 1 To UBound(a)
If a(i)temp Then
temp = a(i)
End If
If a(i)0 Then
n = n1
End If
Next
str = str"正数逗号vb.net的个数为 "n
str = str"最大元素逗号vb.net的下标为 "
For i = 1 To UBound(a)
If a(i) = temp Then
str = stri" "
End If
Next
TextBox6.Text = str
VB.net中任何提取文本文件中的逗号分格数据?用数组呗 。我是用VB6的 , 不过你会.NET也肯定能看懂 。
不是文本文件么?先用Line Input读每行存入数组 。再把每行数据用你的","分割,就可以查询了 。我写个简单的例子:
'搜索函数,用法Search(标头,序号),返回数据.
Private Function Search(ByVal Section As String, ByVal Index As Integer) As String
Dim fNum%, Lines%, temp%, Str As String
ReDim Data(0)
fNum = FreeFile()
If Dir("C:\\1.txt") = "" Then Exit Function
'文件路径和文件名你自己改
Open "C:\\1.txt" For Input As #fNum
Do While Not EOF(fNum)
Lines = Lines1
'行数
Line Input #fNum, Str
ReDim Preserve Data(Lines)
Data(Lines) = Str
Loop
Close #fNum
If Lines0 Then
Dim tmp() As String
For temp = 1 To UBound(Data)
tmp = Split(Data(temp), ",")
'分割
If tmp(0) = Section Then
Search = tmp(Index - 1)
'因为从0开始所以-1
Exit Function
End If
Next
End If
End Function
比如你要“gc“开头的第5个数据 , 就用Search("gc",5)即可返回45 。
逗号vb.net的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于逗号表达式、逗号vb.net的信息别忘了在本站进行查找喔 。

    推荐阅读