菜鸟问题 帮帮忙 谢谢了

xuebye3 2008-03-10 03:26:19
Private Sub Command1_Click()
Dim a As String, b As String, q1 As String, q2 As String, q3 As String, q4 As String, r1 As String, r2 As String, r3 As String, r4 As String, j1 As String, j2 As String, j3 As String, j4 As String
Open "1.txt" For Input As #1
Line Input #1, string1
Line Input #1, string2
Line Input #1, string3
Line Input #1, string4
Line Input #1, string5
Line Input #1, string6
Line Input #1, string7
Line Input #1, string8
Line Input #1, string9
Line Input #1, string10
Line Input #1, string11
Line Input #1, string12
Close #1
Select Case (Val(Text13.Text))
Case Is = 1
a = string1
Case Is = 2
a = string2
Case Is = 3
a = string3
Case Is = 4
a = string4
Case Is = 5
a = string5
Case Is = 6
a = string6
Case Is = 7
a = string7
Case Is = 8
a = string8
Case Is = 9
a = string9
Case Is = 10
a = string10
Case Is = 11
a = string11
Case Is = 12
a = string12
End Select
q1 = Split(a, ",")(0)
q2 = Split(a, ",")(1)
q3 = Split(a, ",")(2)
q4 = Split(a, ",")(3)
q5 = Split(a, ",")(4)
q6 = Split(a, ",")(5)
q7 = Split(a, ",")(6)
q8 = Split(a, ",")(7)
q9 = Split(a, ",")(8)
q10 = Split(a, ",")(9)
q11 = Split(a, ",")(10)
q12 = Split(a, ",")(11)
很罗嗦 而且split函数那边还 越界了 哪出问题了 ?大哥们 帮忙下
...全文
52 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
xuebye3 2008-03-10
以上结果第一行的第二个字符 怎么会是第一行第一个字符?
回复
qiu5208 2008-03-10


'在窗口中加一个按钮即可
Private Sub Command1_Click()
Dim aa As String
Dim i As Integer
Dim j As Integer
'排错
On Error GoTo a:
'打开文件读取整个字串
Open "e:\temp.txt" For Input As #1
aa = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1

Dim Row() As String
Dim y() As String

'读取一行
Row() = Split(aa, vbNewLine)
i = InputBox("请输入读取文本的第几行")

y() = Split(Row(i - 1), ",")

j = InputBox("请输入读取这一行的第几个字串")

MsgBox "第" & i & "行" & "第" & j & "个" & "字串是" _
& (y(i - 1))

'除错部分
Exit Sub
a:
MsgBox "这个字串不存在,或文件不存在"


End Sub
回复
慕容红雪 2008-03-10
检查一下你的逗号是不是够用啊,另外如果越界是发生在第一次访问数组的时候,检查一下你的option base指定的数组下标是从0开始,还是从1开始。
回复
xuebye3 2008-03-10
嗯 实现读取一个多行多列的文本 在文本框内输入指定数值 可以读取指定行
行的字符串用,分隔的
把他剔除出来到数组
比如"12,333,4444,555,6666"
想要第三个"444"就读取 想要第5个就读取
回复
qiu5208 2008-03-10
呵呵,又一典型的蹩脚程序。
错误一堆,
你就把程序要实现的意图说一下。
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7518

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2008-03-10 03:26
社区公告
暂无公告