Asemien, hakemistojen ja tiedostojen luetteloinnin vb.net kielellä.
Tee
Form1
Textbox1, multiline päälle ja vertical scroll päälle
Button1,Button2,Button3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ShowFolders() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ShowDrives() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click ShowFiles() End Sub Private Sub ShowFolders() Dim s() As String Dim a As Long Dim I As Long s = System.IO.Directory.GetDirectories("c:\") a = UBound(s) TextBox1.Text = "" For I = 1 To a TextBox1.Text = TextBox1.Text & s(I) & Chr(13) & Chr(10) Next I End Sub Private Sub ShowDrives() Dim d() As String Dim a As Long Dim I As Long d = System.IO.Directory.GetLogicalDrives() a = UBound(d) TextBox1.Text = "" For I = 1 To a TextBox1.Text = TextBox1.Text & d(I) & Chr(13) & Chr(10) Next I End Sub Private Sub ShowFiles() Dim d() As String Dim a As Long Dim I As Long d = System.IO.Directory.GetFiles("c:\") a = UBound(d) TextBox1.Text = "" For I = 1 To a TextBox1.Text = TextBox1.Text & d(I) & Chr(13) & Chr(10) Next I End Sub
huh... viimeset 5 koodivinkkiä kaikki sun kirjottamia :)
minkätakia mulla näkyy melkeen kaikissa koodeissa punasena tekstit esim
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ShowFolders() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ShowDrives() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click ShowFiles() End Sub
nämä näkyy punasena se ei tunnista noita komentoja
taitaa olla sulla uudempi versio vb:stä ku 6
Kiitosta tästä.
Tästä oli apua.
Aihe on jo aika vanha, joten et voi enää vastata siihen.