Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 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, 2008, 09:17 AM
Registered User
 
Join Date: Jan 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default General Naming(reaching) buttons

Hello everybody!
I am so angry with... I spent one night and whole day to get out of this stuck.

I have problem with naming my button. For example:I have my own XPbutton(UserControl). I want to put the code in core of this control, because on form I have always 2 buttons. button1 name "btn(0)" and button2 named "btn(1)". So it is a control array(name is "btn" and indexes are 0 and 1. I want that whenever after the button1 "btn(0)" is presseed, the button2 "btn(1)" will change the caption. I solve the problem with For Each....IfTypeOf...etc, but I don't wanna use this solution, because if I use that solution, sth else go wrong. So I want just strictly change the caption of button.

If I use Screen.ActiveForm.btn(1).Caption = "yes" - this works. But this are my navigation btns, so I want to use them many times. So I did :
dim bName as string: bName = ScreenActiveControl.Name
dim bInd as Byte: bInd=Screen.ActiveControl.Index. So far so good.

Now I just want to locate:
Screen.Activeform.Contorls(bName(bInd+1)).Caption = "Caption for Second Button" -- Of course this doesn't work, but how can I solve this. Once again, I dont want to use For Each sentence.

Please any suggestion?

Greetings from Slovenia.
Thanks


 
Old January 7th, 2008, 06:13 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Keke,

You need to re-read your posts before submitting them. If you are writing programs, you at least know that there must be a matching “)” for every “(”. Yet just the text of your post has mis-matched parentheses.

Your post is scatter-brained. If you focus, help will be easier to provide.

Screen.ActiveForm.Controls(bName)(bInd + 1) might work. Or
Screen.ActiveForm.Controls(bName).Index(bInd + 1)

You must provide code that distinctly specifies the control array, and then, in a separate paren, identifieds the "element" of that array. Think of this as a two-dimensional array.

Greetings back to you from the United States of America.
 
Old January 7th, 2008, 09:49 PM
Registered User
 
Join Date: Jan 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian, Sorry. I am focused and I know what I want but is my English terrible. Sorry again. And this is just my hobby, so I hope I am not so bad in genetic wich is my profession.

Brain, If I can I will vote you for a president :))))
Screen.ActiveForm.Controls(bName)(bInd + 1) -- WORKS.

Thanks again.


 
Old January 8th, 2008, 05:05 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I think I would make an outstanding president! Not only would my country be in better shape after my first term, there would be spillover helping the whole world enjoy consequential benefits.

But alas, I fear the victory goes to the person who looks best in a photograph, irrespective of their positions or capabilities...





Similar Threads
Thread Thread Starter Forum Replies Last Post
My Comments on reaching the end of the book Nick Y BOOK: Ivor Horton's Beginning Visual C++ 2005 0 August 5th, 2006 07:26 AM
Reaching a subform through code ! penta Access 23 April 5th, 2005 05:50 AM
Naming a new table SKE Classic ASP Databases 2 March 23rd, 2005 03:25 PM
Stored Procedure Naming jmurdock BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 2 July 2nd, 2004 10:22 AM
Naming conventions jara VS.NET 2002/2003 3 June 22nd, 2003 04:21 AM





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