大神求助
vb.net吧
全部回复
仅看楼主
level 2
Public Class Form1
Public n, ashu, cshu As Integer
Public a(), c() As String
Public Function dividestring(s As String, d As String, b() As String) As Integer
Dim i, j, num As Integer
i = InStr(s, d)
j = 1
Do While i > 1
num += 1
ReDim Preserve a(num)
b(num) = Mid(s, j, i - j)
j = i + 1
i = InStr(j, s, d)
Loop
num += 1
ReDim Preserve a(num)
b(num) = Mid(s, j, Len(s) - j + 1)
dividestring = num
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim i As Integer, j As Integer, l As Integer
Dim b() As String
FileOpen(1, "c:\content.txt", OpenMode.Input)
FileOpen(2, "c:\detail.txt", OpenMode.Input)
Do
j += 1
ReDim Preserve c(j)
c(j) = LineInput(2)
If EOF(2) = True Then
cshu = j
Exit Do
End If
Loop
Do
i += 1
ReDim Preserve a(i)
a(i) = LineInput(1)
If EOF(1) = True Then
ashu = i
Exit Do
End If
Loop
ReDim Preserve a(i + 1)
a(i + 1) = ""
For i = 1 To ashu
l = dividestring(a(i), ",", b())
ListBox1.Items.Add(b(1) & "次")
Next
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim i As Integer
Dim c As Integer
Dim bf() As String
ListBox1.Items.Clear()
For i = 1 To ashu
c = dividestring(a(i), ",", bf())
ListBox1.Items.Add(bf(1) & "次")
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim a As String
a = InputBox("请输入要搜索的城市:", "途经城市")
If a = "" Then Exit Sub
Dim i, j, k As Integer
Dim zf() As String
ListBox1.Items.Clear()
For j = 1 To cshu
i = dividestring(c(j), ", ", zf())
If zf(1) = a Then
k = j
Do While c(k) <> "*"
k = k - 1
Loop
ListBox1.Items.Add(c(k + 1) & "次")
End If
Next
If k = 0 Then
Call MsgBox("没有相关城市", 16, "注意")
End If
End Sub
为什么对函数过程进行引用时显示
错误2索引数少于索引数组的维数。C:\Users\lenovo\Documents\Visual Studio 2013\Projects\WindowsApplication1\WindowsApplication1\Form1.vb6243WindowsApplication1
错误1索引数少于索引数组的维数。C:\Users\lenovo\Documents\Visual Studio 2013\Projects\WindowsApplication1\WindowsApplication1\Form1.vb6243WindowsApplication1
错误3 索引数少于索引数组的维数。C:\Users\lenovo\Documents\Visual Studio 2013\Projects\WindowsApplication1\WindowsApplication1\Form1.vb6243WindowsApplication1[泪]
2016年03月24日 12点03分 1
level 2
函数的目的是为了拆分字符串
2016年03月24日 13点03分 2
level 2
数组b()存储拆分的每一段字符串
2016年03月24日 13点03分 3
level 9
把你要匹配的文本内容贴出来。
---贴吧极速版 For UWP
2016年03月24日 16点03分 4
level 2
content文本
T52/T53, 上海, 乌鲁木齐, 18:20, 21:04
T54/T51, 乌鲁木齐, 上海, 10:07, 13:03
T65, 北京, 南京西, 20:40, 8:24
T66, 南京西, 北京, 20:46, 8:31
T85, 北京, 苏州, 17:01, 6:54
T86, 苏州, 北京, 17:07, 7:02
T118/T115, 兰州, 上海, 8:37, 12:41
T116/T117, 上海, 兰州, 15:40, 19:23
T137/T140, 西安, 上海, 18:26, 11:25
T138/T139, 上海, 西安, 15:08, 8:06
T701, 南京西, 杭州, 8:31, 14:00
T706, 杭州, 南京西, 14:22, 20:09
T702/T705, 上海, 铜陵, 7:00, 13:15
T708/T703, 铜陵, 上海, 14:27, 20:40
T711, 南京西, 宁波, 7:40, 15:45
T712, 宁波, 南京西, 9:20, 17:38
T713, 南京西, 上海, 12:43, 16:12
T714, 上海, 南京西, 8:00, 11:06
T721, 南京西, 上海, 14:28, 17:33
T722, 上海, 南京西, 9:00, 12:05
T131/T134, 大连, 上海, 11:57, 11:57
T132/T133, 上海, 大连, 16:03, 15:56
T112/T113, 南京西, 兰州, 16:17, 17:44
T114/T111, 兰州, 南京西, 20:38, 22:12
K45, 北京, 福州, 9:03, 19:42
K46, 福州, 北京, 11:26, 22:20
K56/K57, 上海, 哈尔滨, 9:21, 16:31
K58/K55, 哈尔滨, 上海, 14:01, 21:36
detail文本
*
T52/T53
上海, ---, 18:20
苏州, 19:00, 19:04
无锡, 19:27, 19:31
常州, 19:58, 20:02
南京, 21:17, 21:21
蚌埠, 23:08, 23:16
郑州, 4:11, 4:19
西安, 10:52, 11:00
宝鸡, 12:52, 13:00
天水, 15:35, 15:41
兰州, 21:26, 21:38
武威南, 2:00, 2:08
金昌, 3:10, 3:12
张掖, 5:14, 5:16
嘉峪关, 7:31, 7:39
低窝铺, 8:44, 8:46
敦煌, 10:51, 10:57
哈密, 13:46, 13:54
鄯善, 17:09, 17:15
吐鲁番, 19:01, 19:03
乌鲁木齐, 21:04, ---
*
T54/T51
乌鲁木齐, ---, 10:07
吐鲁番, 12:11, 12:13
鄯善, 13:56, 14:02
哈密, 17:15, 17:23
敦煌, 20:22, 20:28
低窝铺, 22:20, 22:22
嘉峪关, 23:36, 23:44
张掖, 1:56, 1:58
金昌, 3:58, 4:00
武威南, 5:00, 5:08
兰州, 9:36, 9:44
天水, 15:34, 15:47
宝鸡, 18:23, 18:31
西安, 20:22, 20:30
郑州, 3:04, 3:12
蚌埠, 8:07, 8:15
南京, 10:02, 10:06
常州, 11:20, 11:24
无锡, 11:48, 11:52
苏州, 12:14, 12:18
上海, 13:03, ---
*
T65
北京, ---, 20:40
济南, 1:11, 1:19
蚌埠, 6:06, 6:14
南京, 8:01, 8:16
南京西, 8:24, ---
*
T66
南京西, ---, 20:46
南京, 20:54, 21:09
蚌埠, 22:57, 23:05
济南, 3:44, 3:52
北京, 8:31, ---
程序的目的是实现列车时刻查询,多谢!!!
2016年03月25日 14点03分 6
level 9
2016年03月26日 11点03分 8
这个源码能贴出来看看吗?多谢
2016年03月27日 03点03分
level 13
能写得正常点吗?FileOpen(String,Int32),EOF(Int32) 这些都是用来移植vb6代码用的,性能很差。
---贴吧极速版 For UWP
2016年03月26日 12点03分 9
正常是什么意思,不然怎么弄
2016年03月27日 03点03分
回复 研发的老巢 : 用FileStream,如果文件小可以File.ReadAllText ---贴吧极速版 For UWP
2016年03月27日 03点03分
@Nukepayload2 这是导致无法运行的原因吗?求教
2016年03月27日 04点03分
回复 研发的老巢 : 不一定。但是能帮你更快确定问题所在。 ---贴吧极速版 For UWP
2016年03月27日 04点03分
level 8
代码太多不想看[汗]
只想说一点,拆分字符串有那么麻烦么?
Dim word_list as string
Dim Split_word() as string = word_list.Split(",")
直接用Split拆分不更快么?
2016年03月27日 03点03分 10
有Split不用自己写轮子是不明智的[汗]
2016年03月27日 03点03分
@杨宇成12345 我刚学,水平有限
2016年03月27日 04点03分
@杨宇成12345 这个拆分后可以把各段装进数组里吗?
2016年03月27日 04点03分
@花开伊人笑桥CQ 拆分完后Split_word()里就是拆分数据,直接像数组一样操作Split_word(0),Split_word(1)等。。就可以了
2016年03月27日 05点03分
1