MichaelQuestion MichaelQuestion - 10 months ago 38
Vb.net Question

VisualBasic- How to tell a Log to make a new line? ^^

So I made a TextBox and I want to display a small test log in there.
I told my button to print a Test Text there whenever it gets pressed:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Button1Click As Boolean
TextBox2.Text = Random()
Button1Click = True
If Button1Click Then
TextBox1.Text = ("Generated ID:" & Random())
TextBox1.Text = "LELELELELLE"
End If
Button1Click = False
End Sub

The function Random just prints some random numbers there. Ofc it is working and it prints out that: GeneratedID: asd293r04orwr04fjdl BUT the Random numbers always get generated new IN THAT LINE. I want the button to add new lines whenever it is pressed so it looks like that:

  1. GeneratedID: asd293r04orwr04fjdl

  2. GeneratedID: asdsaghbnmk777777

  3. GeneratedID: ad49kvß4ßfg3ßtß4

Without the 1,2,3... just because of the strange formatting here.

But how? ^^ I tried vbNewLine but it just didnt work.


First make sure that TextBox1.Multiline is true.

TestBox1.AppendText("Generated ID:" & Random() & Environment.NewLine)

should work.