如何将第一行的数据显示在一个list1列表中,然后选择相应的数据,在list2列表中显示所对应的数据,然后list2中只显示数据的第一列,当在list2中选择相应的数据时,又能在text1和text2中显示相应的第二列和第三列数据。谢谢!还有在增加第一行数据时,比如我要增加一个d,e系列的参数时,程序能自动的调入。数据格式如下:a,b,cstart_a
1,2,3
4,5,6
7,8,9
end_astart_b
10,20,30
40,50,60
70,80,90
end_bstart_c
100,200,300
400,500,600
700,800,900
end_c
1,2,3
4,5,6
7,8,9
end_astart_b
10,20,30
40,50,60
70,80,90
end_bstart_c
100,200,300
400,500,600
700,800,900
end_c
Dim arrLine1() As String
Private Sub Command1_Click()
Dim strTmp1 As String, tmp1 As String
Open "c:/file1.txt" For Input As #1
Do Until EOF(1)
Line Input #1, tmp1
If Len(Trim(tmp1)) <> 0 Then
strTmp1 = strTmp1 & tmp1 & vbCrLf
End If
Loop
Close #1arrLine1 = Split(strTmp1, vbCrLf)List1.Clear
Dim strTmp() As String, i As Long
strTmp = Split(arrLine1(0), ",")
For i = 0 To UBound(strTmp)
List1.AddItem Trim(strTmp(i))
NextEnd SubPrivate Sub List1_Click()
Dim strTmp As String, i As Long
strTmp = LCase("start_" & List1.Text)
List2.Clear
For i = 1 To UBound(arrLine1)
If LCase(Trim(arrLine1(i))) = strTmp Then
List2.AddItem arrLine1(i + 1)
Exit For
End If
Next
End SubPrivate Sub List2_Click()
Dim strTmp As String, i As Long
strTmp = List2.TextFor i = 1 To UBound(arrLine1)
If LCase(Trim(arrLine1(i))) = LCase(Trim(strTmp)) Then
Text1.Text = arrLine1(i + 1)
Text2.Text = arrLine1(i + 2)
Exit For
End If
Next
End Sub
没有考虑不同的
START_X
END_X
中间若有重复数据的情况吃饭去了哦
Private Sub List2_Click()
Dim strTmp As String, i As Long
strTmp = LCase("start_" & List1.Text)For i = 1 To UBound(arrLine1)
If LCase(Trim(arrLine1(i))) = strTmp Then
Text1.Text = arrLine1(i + 2)
Text2.Text = arrLine1(i + 3)
Exit For
End If
Next
End Sub
我的意思是list1显示了a,b,c了,在list1中选择了a,会在list2中显示1,4,7,而不是第一行的数据,准确的说是显示第一列的数据,不好意思,在text1,和text2中显示相应的2,5,8和3,6,9。谢谢!
不过还是谢谢,我是初学,不好意思!
在list2中显示1,4,7,然后选择1,在text1,和text2中显示相应的2和3。以此类推!
两个list
代码如下:
Dim a() As String, n%
Private Sub List1_Click()
For j = 0 To UBound(a)
If List1.Selected(j) = True Then
List2.Clear
List2.AddItem 1 * 10 ^ j
List2.AddItem 4 * 10 ^ j
List2.AddItem 7 * 10 ^ j
n = j
End If
Next j
End SubPrivate Sub List2_Click()
If List2.Selected(0) = True Then
Text2.Text = 2 * 10 ^ n
Text3.Text = 3 * 10 ^ n
End If
If List2.Selected(1) = True Then
Text2.Text = 5 * 10 ^ n
Text3.Text = 6 * 10 ^ n
End If
If List2.Selected(2) = True Then
Text2.Text = 8 * 10 ^ n
Text3.Text = 9 * 10 ^ n
End If
End SubPrivate Sub Text1_Change()
str1 = Text1.Text
a = Split(str1, ",")
List1.Clear
For i = 0 To UBound(a)
List1.AddItem a(i)
Next i
End Sub
qw,dfg,x,Hstart_qw
L20×20×3,0.899
L20×20×4,1.145
L25×25×3,1.124
L25×25×4,1.459
L30×30×3,1.373
L30×30×4,1.786
L36×36×3,1.656
end_qwstart_dfg
C50×37×4.5,5.438
C63×40×4.8,6.63
C80×43×5,8.04
C100×48×5.3,10
C126×53×5.5,12.31
end_dfgstart_x
I100×68×4.5,11.25
I126×74×5,14.21
I140×80×5.5,16.88
I160×88×6,20.5
I180×94×6.5,24.13
I200×100×7,27.91
I200×102×9,31.05
I200×110×7.5,33.05
I200×112×9.5,36.5
end_xstart_H
H96×100×5×8,16.7
H100×100×6×10,20.4
H120×106×12×20,41.8
H114×120×5×8,19.9
H120×120×6.5×11,26.7
H140×126×12.5×21,52.1
end_H