我希望不是像下列的程式碼內建
而是能直接由檔案讀出
請問怎麼寫呢?

Dim stu_name(5) As String, school(5) As String
Private Sub Command1_Click()
For i = 0 To 5
    If Text1.Text = stu_name(i) Then
      Text2.Text = school(i)
      Exit Sub
    End If
  Next i
  Text2.Text = "找不到您輸入的姓名"
End Sub
Private Sub Form_Load()
stu_name(0) = "NIKE": stu_name(1) = "ADIDAS": stu_name(2) = "MISUNO"
  stu_name(3) = "ALLSTAR": stu_name(4) = "HENTENG": stu_name(5) = "KIMKO"
  school(0) = "臺灣大學": school(1) = "清華大學": school(2) = "臺灣科技大學"
  school(3) = "交通大學": school(4) = "成功大學": school(5) = "遠東科技大學"
  Text1.Text = ""
  Text2.Text = ""
End Sub


在下去是我自己的寫法
Dim cus_name(100) As String, tel1(100) As String, tel2(100)
As String, where1(100) As String, where2(100) As String
Private Sub Command1_Click()
For i = 0 To 100
    If Text6.Text = cus_name(i) Then
        Text7.Text = tel1(i)
        Text8.Text = tel2(i)
        Text9.Text = where1(i)
        Text10.Text = where2(i)
        Exit Sub
     End If
  Next i
  Text2.Text = "找不到您輸入的姓名"
End Sub
就是要這裡用讀檔的而不是像上面一樣內建
Private Sub SSTab1_DblClick()
Open "customer.text" For Input As #1
  List1.Clear
    For i = 0 To 100
      Do While Not EOF(1)
        
      Input #1, cus_name(i), tel1(i), tel2(i), where1(i), where2(i)

Loop
    Next i
  Close #1
End Sub
創作者介紹
創作者 vbqa 的頭像
vbqa

小吳 VBQA 程式設計討論

vbqa 發表在 痞客邦 留言(3) 人氣()