vb.net 根据给定条件判断该内容是否在数组中,并读取该条数组
Imports System.IO
创新互联建站于2013年开始,先为焦作等服务建站,焦作等地企业,进行企业商务咨询服务。为焦作企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
Imports System.Collections
Imports System.Text
Public Class Form1
Dim InfoList As New ArrayList
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim fs As New FileStream("c:\1.txt", FileMode.Open, FileAccess.Read, FileShare.None)
Dim fw As New StreamReader(fs, Encoding.Default)
Do Until fw.EndOfStream
InfoList.Add(fw.ReadLine)
Loop
fw.Close()
fs.Close()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim tmp As String, a As Integer
a = -1
tmp = TextBox1.Text
For i = 0 To InfoList.Count - 1
If InStr(InfoList.Item(i).ToString, tmp) 0 Then a = i : Exit For
Next
If a = 0 Then TextBox2.Text = InfoList.Item(a)
End Sub
End Class
vb.net中如何取多维数组的某一维
你说的某一维只得是某一维的什么 数组么?还是说某一维的具体对象
vb.net如何在数组中查找数组?
'''这个函数功能就是用来把数组转为string的格式'''如byte()={1,2,3,4,5,6}转化后变为",1,2,3,4,5,6,"Function ByteArrayToString(bytes() As Byte) As String Dim s As String = "" For i As Integer = 0 To bytes.Length s = Convert.ToString(bytes(i)) "," Next Return “," sEnd Function Sub Search()Dim a as byte()={1,2,3,4,5,6}
Dim b as byte()={2,3,4}
Dim astr As String = ByteArrayToString(a)Dim bstr As String = ByteArrayToString(b)Dim index As Integer = astr.IndexOf(bstr) '这个index就是b数组在a数组的位置,下标从0开始,不过记得处理下逗号,因为这时候是字符串。'''如果index小于0说明没有匹配内容End Sub 现在说明下ByteArrayToString为什么要在字符串开头加个",",如果不加,可能出现a="1,23,4,5,6,", b="3,4,5,",结果导致查询位置错误,匹配了a的位置
当前题目:vb.net取数组 vb把数据读入数组
网址分享:http://scgulin.cn/article/hggees.html