Help in VB.NET drawing text to form on Button1_Click?

Lana T

New member
I've programmed in other languages before, but I for some reason just can't wrap my head around .NET. Here is a VB.NET 2010 short little "Hello World!" I made. It writes "Hello World" at a specified location on the form, in a specified color upon form load (actually frmMain_Paint, which I'm not sure I completely understand). That part works.

But I cannot figure out how to add a second message, "Hello World Again!" on the form after clicking Button1. Yes, I've tried to RTFM, but I'm just not finding this.

Can someone help get me in the right direction?

In design mode, it's just a form with a Button1 stuck on there. And then the following code. Hopefully this will paste right in for anyone who wants to try:

'code
Public Class Form1
Public Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim font As Font
font = New System.Drawing.Font("Terminal", 10, FontStyle.Bold)
e.Graphics.DrawString("Hello World!", font, Brushes.White, 100, 10)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'how to: Graphics.DrawString("Hello World Again!", font, Brushes.White, 100, 30) ????
End Sub
End Class
Bobby Lockwood, I tried out the label example as you wrote. It worked fine I just used:

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Label1.Visible = True
End Sub

But what I'm really trying to do is wite text to the form in xy positions at the call of a button_click or timer event, or function call, etc...
 
Back
Top