
正文
vb.net取中间文本框,vb取中间字符
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
VS2013 VB(VB.NET)截取指定文字中间的内容
简单,思路:
1、将每行数据放到数组
2、把”:“作为分隔符拿到你想要的字符串
程序如下:
dim ArrTemp() as string
ArrTemp=split(你的这堆字符,vbcrlf)
dim i as int
dim ArrTemp1() as string
for i=0 to ubound(ArrTemp)
ArrTemp1=split(ArrTemp(i),":")
msgbox left(ArrTemp1(1),len(ArrTemp1(1))-1)
next
相关问答
Q1: vb.net 2010 如何把文本框中的数字提取出来
源代码如下:(代码写在按钮点击事件里)
Label1.Text = ""
Label2.Text = ""
Dim a As String = TextBox1.Text
Dim b As String = TextBox2.Text
For x = 1 To a.Length
Dim txt As String = Mid(a, x, 1)
If txt Like "#" Then
Label1.Text = Label1.Text txt
End If
Next
For x = 1 To b.Length
Dim txt As String = Mid(b, x, 1)
If txt Like "#" Then
Label2.Text = Label2.Text txt
End If
Next
此方法用的是mid 将一个字符串拆分成单个字符,然后用like运算符进行对比是否为数字,关于这两个函数的用法如果不懂的可以自己搜索下,此外还有别的方法,这里就不多说了
Q2: vb.net如何提取文本框中的文本
首先应该在窗口(Form1)上添加一个TextBox1合一个Button1
然后添加以下代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mystring As String
mystring = TextBox1.Text
Msgbox(mystring)
End Sub
总之TextBox1.Text中的TextBox1一定要和你的文本框的名字(Name)相同






