473,321 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Referring form objects in VB 2005.

Hi all,

I'm converting a VB 6 exe project to a VB 2005 project.

One main functionality in VB 6 that gives errors in VB 2005 project is
as follows:

In VB6, i have a initial form called frmApplication that loads up.
There are two other forms Form1 and Form2. Based on the user settings,
frmApplication then loads either Form1 or Form2. Form1 and Form2
differs only by appearance. What i mean, all the controls in both the
forms are same including the name except there position of the control
on the respective forms.

When frmApplication is loaded, it creates a object of Form1 or Form2
depends on the setting and assigns to frmObject.

Now in VB6, i access the controls in Form1 or Form2 in runtime using

frmObject.lblName.Caption = "Somename"

While in VB 2005, i'm not able to refer the controls in the similar
manner. How is it possible to get the same functionality in VB 2005.

Thanks,
Sugan.

Jul 12 '06 #1
2 1222
Select this control (and all other appropriate controls) and set its "
Modifiers" property to whatever best fit (such as "friend"). Controls in VB
2005 are "private" by default.
Another option would be to expose this as a property instead of exposing the
control directly.

Also what is the type of frmObject ? It will work if you are using late
binding but if you want to use strong typing you'll have to use a type that
is compatible with both forms...

Another option could be to move the controls by code (as it seems the only
difference is their position).
--
Patrice

"Sugan" <vs****@gmail.coma écrit dans le message de news:
11*********************@b28g2000cwb.googlegroups.c om...
Hi all,

I'm converting a VB 6 exe project to a VB 2005 project.

One main functionality in VB 6 that gives errors in VB 2005 project is
as follows:

In VB6, i have a initial form called frmApplication that loads up.
There are two other forms Form1 and Form2. Based on the user settings,
frmApplication then loads either Form1 or Form2. Form1 and Form2
differs only by appearance. What i mean, all the controls in both the
forms are same including the name except there position of the control
on the respective forms.

When frmApplication is loaded, it creates a object of Form1 or Form2
depends on the setting and assigns to frmObject.

Now in VB6, i access the controls in Form1 or Form2 in runtime using

frmObject.lblName.Caption = "Somename"

While in VB 2005, i'm not able to refer the controls in the similar
manner. How is it possible to get the same functionality in VB 2005.

Thanks,
Sugan.

Jul 12 '06 #2
Hi,

Thanks for your reply. As you said in your second para, i'm using late
binding.

Here is my VB 6 code.

Code:

Dim frmObject as form

Private Sub Form_Load() 'frmApplication_load

If UserSetting = 1 then ' Check the appearnce required by user
frmObject = New Form1
Else
frmObject = New Form2
End if

'Both the forms have the same controls ( their name is even same)
except for 'their positions in the corresponding form. So now i access
as

frmObject.lblName.Caption = "Somename"

'I need how about to do this as frmObject is not visible in My.Forms

End sub

Thanks,
Sugan

Jul 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike Brearley | last post by:
I was wondering if there was an easy way to have a form set up so that when the submit button is pressed, it goes to a confirmation page that contains a back button that goes back to the page that...
2
by: david | last post by:
Hi, I have a form with 2 select objects which are not linked together in any way. The list exactly the same information. The code that generates the data is: ...
17
by: Barret Bonden | last post by:
As an old programmer just now looking at VB.net I have a question: How does one simply open one form from another ? I don't mean how does one create a new instance of that form , but rather how...
1
by: dm1608 | last post by:
Hi all -- I'm rapidly learning ASP.NET 2.0 (never really did much .NET before... mainly an ASP and PHP guy until now) and seem to be having some technical challenges that I'm hoping someone can...
3
by: kpuchala | last post by:
Hello I'm beginnig to create my first application in Visual Web Debeloper 2005 Express. I need to create a web site (simple application), which will allow to list objects (records) stored in...
2
by: Jerry Spence1 | last post by:
One way of passing data to a thread is to encapsulate the thread inside a class. However, I can't refer to my main form objects from within the class/thread as it says "Reference to a non-shared...
5
by: jeremy | last post by:
I have an ASP.Net 2.0 application running on Windows Server 2003. The application displays properly in Internet Explorer, however, when I use a browser control embedded in a .net form, I get an...
2
by: paladin | last post by:
We have a strange situation where some of the referring URL's are missing from our log files. This is on .NET application on IIS 6.0. Here is what is happening: Page a.aspx has a form that...
2
by: deccio | last post by:
I have create an activex Control with Visual studio 2005 and framework 2.0 in c# to add drag & drop functionality to upload multi file. When I use it in a windows form it work fine. Infact if I...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.