Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2005, 08:33 AM
Authorized User
 
Join Date: Nov 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Printing name and index of a control

Hi,

I wanted to print the name of a control (like if it's a text box --> textbox, not the name I've given to that) and the index in form of that control (it's prefered if there are more than one of that control, index amongst them.). It's something I came up while watching Joe Hummel's webcasts. The code I wrote is here, unfortunately it doesn't work:
------------------------------------------------
Private Sub Common_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

Dim txt As TextBox

txt = sender

Dim printstr As String

Globals.Changed = True

printstr = "New text of " & TypeOf(txt).ToString & "(" & txt.Parent.Controls.IndexOf(txt).ToString & "): " & txt.Text

System.Diagnostics.Debug.WriteLine(printstr)

End Sub
------------------------------------------------

Any help?


 
Old January 5th, 2005, 10:38 AM
Authorized User
 
Join Date: Nov 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

System.Diagnostics.Debug.WriteLine("New text: " & txt.GetType.Name & Me.Controls.IndexOf(txt).ToString & " ")

It's closer to what I was looking for. However I can't get index of a textbox amongst other textboxes but I get indexes of controls regardless of type in form (as expected).






Similar Threads
Thread Thread Starter Forum Replies Last Post
Index carumuga SQL Server 2000 1 December 31st, 2007 12:42 PM
capturing printing settings when printing reports nikolaosk Access VBA 0 February 8th, 2005 04:14 AM
Crystal Printing from ASP active X control Problem jimh78 Crystal Reports 0 September 25th, 2003 03:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.