Hey,
I tried to change the size of a label from 2 text boxes, but doesn't work. Here is my code:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        y = TextBox2.Text
        x = TextBox3.Text
        Form2.Label1.Size = New Size(y, x)
    End Sub

textbox2 is width and textbox3 is height.
It doesn't change and I don't know why. Can someone help me with this?

Turn "AutoSize" off on the Label1.

Turn "AutoSize" off on the Label1.

I tried and still not working, any other ideas?

Hey,
I tried to change the size of a label from 2 text boxes, but doesn't work. Here is my code:
VB.NET Syntax (Toggle Plain Text)

1.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
2.
y = TextBox2.Text
3.
x = TextBox3.Text
4.
Form2.Label1.Size = New Size(y, x)
5.
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click y = TextBox2.Text x = TextBox3.Text Form2.Label1.Size = New Size(y, x) End Sub
textbox2 is width and textbox3 is height.
It doesn't change and I don't know why. Can someone help me with this?

Forgot to add:

Dim y As Integer
    Dim x As Integer
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        y = TextBox2.Text
        x = TextBox3.Text
        Form2.Label1.Size = New Size(y, x)
    End Sub

Hi,

You should do it like this:

In form1 you need a button to show your form2 like this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fr As New Form2
        fr.Show()
    End Sub

In form2 you can do it like this:

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim y As Integer
        y = Form1.TextBox1.Text
        Dim x As Integer
        x = Form1.TextBox2.Text

        Label1.Size = New Size(y, x)
    End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
        Dim W As Integer = TextBox1.Text
        Dim H As Integer = TextBox2.Text
        Label1.Size = New Point(W, H)
    End Sub

I use it and it work Turn off Autosize And to test it work just change BackColor
to other color
the font size didn't change as it label size you must code it

Dim fnt As Font
fnt = TextBox1.Font
Label1.Font = New Font(fnt.Name, 12, FontStyle.Bold)

VB.NET Syntax (Toggle Plain Text)

1.
Private Sub Button1_Click(ByVal sender As System.Object, _
2.
ByVal e As System.EventArgs) Handles Button1.Click
3.
Dim W As Integer = TextBox1.Text
4.
Dim H As Integer = TextBox2.Text
5.
Label1.Size = New Point(W, H)
6.
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim W As Integer = TextBox1.Text Dim H As Integer = TextBox2.Text Label1.Size = New Point(W, H) End Sub
I use it and it work Turn off Autosize And to test it work just change BackColor
to other color
the font size didn't change as it label size you must code it
VB.NET Syntax (Toggle Plain Text)

1.
Dim fnt As Font
2.
fnt = TextBox1.Font
3.
Label1.Font = New Font(fnt.Name, 12, FontStyle.Bold)

Well, them how can I change the size of text using those text boxes?

Private Sub Button1_Click(ByVal sender As System.Object, _
Dim TxtSz As Integer = Textbox1.text
Dim fnt As Font
fnt = Label1.Font
Label1.Font = New Font(fnt.Name, TxtSz, FontStyle.Regular)
End Sub

This Work For Me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.