Getting H & W Values of your Form
Use this board to post your code snippets - tips and tricks
10 posts
Page 1 of 1
Hi All
As i was searcing around my External Harddrive i came across this, A very simple way of getting your Height and Width Size of your Form.
On your Form
2 textbox's
2 Labels
1 Timer ( interval =1 & Enabled)
Timer Tick Code
Form set up
And as you drag out the Form/Window with your Mouse or Maximise your Window it will
adjust your Width and Height Coordinates.
Anyways, I just thought I would post this up for those who are Interested
Attachment Below ( working ex )
Chris
As i was searcing around my External Harddrive i came across this, A very simple way of getting your Height and Width Size of your Form.
On your Form
2 textbox's
2 Labels
1 Timer ( interval =1 & Enabled)
Timer Tick Code
Code: Select all
And that is it TextBox1.Text = me.Height
TextBox2.Text = Me.Width
Form set up
And as you drag out the Form/Window with your Mouse or Maximise your Window it will
adjust your Width and Height Coordinates.
Anyways, I just thought I would post this up for those who are Interested
Attachment Below ( working ex )
Chris
You do not have the required permissions to view the files attached to this post.
You don't need a timer for that. You can put it in the Resizing event which triggers whenever the form has changed size.
this is for newer members Harlem not for the better coders
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that
Wouldn't newer members find it easier to use the resize event?
"Well i just can across it and Posted it up" Just in case anyone was Interested
Why dont you recreate one your way and Post it up and we can see the differences and the Code that lays behind it?
Chris
Why dont you recreate one your way and Post it up and we can see the differences and the Code that lays behind it?
Chris
Code: Select all
Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
TextBox1.Text = Me.Height
TextBox2.Text = Me.Width
End Sub
This will update the size when the text boxes are changed:
Code: Select all
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
try
me.width = textbox1.text
catch ex as exception
MsgBox("Error: " & ex.message)
end try
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
try
me.Height = TextBox2.text
catch ex as exception
MsgBox("Error: " & ex.message)
end try
End Sub
That isn't too clever considering as soon as you type in the first number (e.g. a 2) the width or height would be '2' and the textbox wouldn't be visible.
I posted something very close to this here. Although I didn't have a timer, I had 2 labels, 2 textboxs, and a button.
10 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023