• Register now to get access to thousands of Tutorials, Leaked content, Hot NSFW and much more. Join us as we build and grow the community.

Advertise Here

Advertise Here

Advertise Here

How to Get the X/Y Point of a Textbox Using For Each Loop

matts11

Upsell Wizard
M Rep
0
0
0
Rep
0
M Vouches
0
0
0
Vouches
0
Posts
133
Likes
66
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 100 XP
In this tutorial I will teach you how to get X/Y Point of a Textbox Using For Each Loop in Visual Basic 2008. With this you can easily get the location of a specific Textbox. I used the Foreach Loop so that you don’t have to specify what is the name of your Textbox. All you have to do, is to get the type of it.

Let’s begin.

Open Visual Basic 2008, create a new Windows Application, drag the Textbox and Button you needed. It will look like this.

first_0.png


After that, double click the button to fire the click

event handler. 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. 'FOR EACH TXT AS WINDOWS FORMS CONTROL IN THE FORM 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. 'GETTING THE TYPE OF THE TXT CONTROL.
  7. If

    txt.

    GetType

    Is

    GetType

    (

    TextBox)

    Then
  8. 'IF THE TYPE OF TXT IS TEXBOX,
  9. 'THE LOCATION OF A SPECIFIC TEXTBOX WILL EXIST INTO IT.
  10. txt.

    Text

    =

    txt.

    Location

    .

    ToString
  11. End

    If
  12. Next

  13. End

    Sub

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

 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

452,499

349,672

349,682

Top