erstellt am: 08. Sep. 2003 20:59 <-- editieren / zitieren --> Unities abgeben: Nur für san
Hallo san,
Private Sub Command1_Click() Dim s() As String Dim Count As Long, i As Long ' Datei öfnen Open "D:\Test.txt" For Input As 1 ' Text in Array lesen Do While Not EOF(1) Count = Count + 1 ReDim Preserve s(Count) Line Input #1, s(Count) Loop ' Zufallsgenerator initialisieren Randomize ' Zufallszahl ermitteln i = Int(Rnd * (Count + 1)) MsgBox s(i) Close 1 End Sub
Hi Pablo habe es mittlerweile anders gelöst und es funktioniert auch:
Set fso = CreateObject("Scripting.FileSystemObject") Set txt = fso.OpenTextFile("c:\temp\Farben.txt") Randomize x = Int(((43 - 1 + 1) * Rnd) + 1) For i = 1 To x Zeile = txt.ReadLine Next txt.Close