How to Get the X and Y Point of the TextBox Using For Each Loop in VB.Net

0
336

This tutorial is all about How to Get the X and Y Point of the TextBox Using For Each Loop in VB.Net.
In this tutorial I will teach you how to get X/Y Point of a Textbox Using For Each Loop in VB.Net. This method is used to get the location of a specific Textbox and I used the Foreach Loop so that, you don’t need to specify the names of it. All you have to do, is to get it’s type.

Let’s begin.
Open the Visual Basic, create a new Windows Form Application, drag the Textbox and Button you needed. Set up the Form just like this.
loactionform
After setting up the Form, double click the Button to fire the click event handler of it. Then, add the following code to the method created.

  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. 'LOOP THE CONTROL ON THE FORM OF CONTROLS
  3. 'ME IS AN OBJECT THAT STANDS AS A FORM
  4. 'CONTROLS ARE BASE CLASS WHICH ARE COMPONENT WITH VISUAL REPRESENTATION
  5. For Each txt As System.Windows.Forms.Control In Me.Controls
  6. 'SET THE TYPE OF THE CONTROL TO A TEXTBOX.
  7. If txt.GetType Is GetType(TextBox) Then
  8. 'GETTING THE LOCATION OF A SPECIFIC TEXTBOX AND WILL APPEAR INTO IT.
  9. txt.Text = txt.Location.ToString
  10. End If
  11. Next
  12. End Sub

Run your project and click the Button to start the code in the method.

 

Readers might read also:

 

 

Facebook Comments
(Visited 11 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here