473,466 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

User defined Form property

Hi Guys

Am I just dumb or is there some new way to get a form property? eg

In frmClient I have:

Private _ClientID As Integer

Public Property ClientID() As Integer
Get
Return _ClientID
End Get
Set (ByVal Value As Integer)
_ClientID = Value
End Set
End Property

In frmMain I do something like this:

Dim frm As Form = New frmClient

With frm
.ShowDiaglogue()
'PROBLEM frm does not expose its property ClientID
If .ClientID > 0 Then 'error here
'do something
End if
End With

What am I doing wrong????? Thanx
Nov 20 '05 #1
3 1023
On 2004-01-29, Harry Strybos <ha***@fin.nospam.anciallyfit.com.au> wrote:
Hi Guys

Am I just dumb or is there some new way to get a form property? eg

In frmClient I have:

Private _ClientID As Integer

Public Property ClientID() As Integer
Get
Return _ClientID
End Get
Set (ByVal Value As Integer)
_ClientID = Value
End Set
End Property

In frmMain I do something like this:

Dim frm As Form = New frmClient
Dim frm As New frmClient

With frm
.ShowDiaglogue()
'PROBLEM frm does not expose its property ClientID
If .ClientID > 0 Then 'error here
'do something
End if
End With

What am I doing wrong????? Thanx


You are assigning the inheriting type to it's base type. Form doesn't
expose a ClientID property :)

--
Tom Shelton [MVP]
Powered By: Gentoo Linux 1.4
You can't go home again, unless you set $HOME.
Nov 20 '05 #2
> Dim frm As Form = New frmClient
'PROBLEM frm does not expose its property ClientID


The variable is declared using Form. The Form class doesn't have a ClientID property, the frmClient class does. Declare your variable using frmClient instead of Form:

Dim frm As frmClient = New frmClient

Or

Dim frm As New frmClient

--
Eduardo A. Morcillo [MS MVP VB]
http://www.mvps.org/emorcillo
Nov 20 '05 #3
> But then this begs the question: what is frm variable set to?

frm is set to a new instance of frmClient. But since its declared "As Form" you will only see the properties and methods exposed by the Form class.
Are you telling me that frm.ClientID doesn't exist?!
It exists, but is not accesible because frm is declared as Form, and is not a property of Form.
Then the above declaration/instantiation should not be allowed
and should cause an error.
Why? If frmClient inherits from Form that construction is valid.
Dim obj As Object = New frmClient

What is obj in the above statement?
A new frmClient instance.
Does it have the ClientID property?


It does, and you can call it if "Option Strict" is set to "Off". Otherwise you will have cast it to frmClient to call it.

--
Eduardo A. Morcillo [MS MVP VB]
http://www.mvps.org/emorcillo
Nov 20 '05 #4

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

Similar topics

5
by: Ed Havelaar | last post by:
I have a cool function that I want to use as a default value for a column in my table. But I can't because apparently Access doesn't allow user defined functions in expressions for default values....
2
by: Liz - Newbie | last post by:
I need to generate an event in a user defined control when I have changed a variable, so that I can pick it up in my main form and take it from there. Can someone explain the SIMPLEST way of...
3
by: Vivek Sharma | last post by:
Hi, I have created a dropdownlist as a web user control. I am using its multiple instances on the webpage. How do I access the selectedValue of each instance? All the instances have different...
1
by: Raj | last post by:
Hi, I have created a Windows 'user control' in C#.NET. This user control defines several public 'properties' that the outer world can use to tweak the behavior of the user control. However,...
12
by: Phil Certain | last post by:
Hi, I'm trying to do something very simple...or at least it should be. I have created a host page (gen.aspx) and a very simple user control (us.ascx). The corresponding code-behind files are...
9
by: abprules | last post by:
Can somehow tell me the best way for multi user development to occur in MS Access? The situation is: We are creating a new database for a small company. There are 2 of us who want to...
2
by: rn5a | last post by:
Assume that a user control has a TextBox (Page1.ascx) <asp:TextBox ID="txtName" runat="server"/> I am encapsulating the above user control in a ASPX page named Page1.aspx i.e. the ASPX page...
0
FishVal
by: FishVal | last post by:
Hereby I'm proposing a way of convinient work with properties containing SQL Select statements, particulary RowSource property of ComboBox and ListBox. The usual way is the following. Private...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.