Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Jak zrobić (pytanie dot .przeglądarki)


Rekomendowane odpowiedzi

Opublikowano
If File.Exists("sayings.txt") Then
    'StreamReader to read our file
    Dim ioFile As New StreamReader("sayings.txt")
    'Generic list for holding the lines
    Dim lines As New List(Of String)
    'Random class to generate our random number
    Dim rnd As New Random()
    'Variable to hold our random line number
    Dim line As Integer
    'Now we loop through each line of our text file
    'adding each line to our list
    While ioFile.Peek <> -1
		    lines.Add(ioFile.ReadLine())
    End While

    'Now we need a random number
    line = rnd.Next(lines.Count + 1)
    'Now write out the random line to the TextBox
    RichTextBox1.AppendText(lines(line).Trim())
    'Close our StreamReader
    ioFile.Close()
    'Dispose of the instance
    ioFile.Dispose()
Else
    Dim ioFile As New StreamWriter("sayings.txt")
    ioFile.WriteLine("Chinese words here")
    ioFile.Close()
End If

 

 

hqdefault.jpg?feature=og

 

 

Opublikowano

If File.Exists("sayings.txt") Then
	'StreamReader to read our file
	Dim ioFile As New StreamReader("sayings.txt")
	'Generic list for holding the lines
	Dim lines As New List(Of String)
	'Random class to generate our random number
	Dim rnd As New Random()
	'Variable to hold our random line number
	Dim line As Integer
	'Now we loop through each line of our text file
	'adding each line to our list
	While ioFile.Peek <> -1
			lines.Add(ioFile.ReadLine())
	End While

	'Now we need a random number
	line = rnd.Next(lines.Count + 1)
	'Now write out the random line to the TextBox
	RichTextBox1.AppendText(lines(line).Trim())
	'Close our StreamReader
	ioFile.Close()
	'Dispose of the instance
	ioFile.Dispose()
Else
	Dim ioFile As New StreamWriter("sayings.txt")
	ioFile.WriteLine("Chinese words here")
	ioFile.Close()
End If

Gówniany kod

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...