I was wondering if it is possible to evaluate a variable to determine if the variable is a control on the current or other form?
Here is what I am currently looking at. I have two date fields that are using a calendar control. Depending upon which date field opened the Calendar Control, I want the date to be passed back to that control. I would prefer not to have two Calendar Controls. Here is what I have attempted so far. - Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
-
calMain.Visible = True
-
lblControl.Text = "txtStartDate"
-
End Sub
-
-
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
-
calMain.Visible = True
-
lblControl.Text = "txtEndDate"
-
End Sub
-
-
Private Sub calMain_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles calMain.DateSelected
-
Dim frmText As New TextBox
-
frmText.Name = lblControl.Text
-
frmText.Text = e.Start.ToShortDateString
-
calMain.Visible = False
-
End Sub
7 2128
Found a work around for this but would still like to know if its possible to evaluate variables.
Work Around: - Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
-
calMain.Visible = True
-
lblControl.Text = "Start"
-
End Sub
-
-
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
-
calMain.Visible = True
-
lblControl.Text = "End"
-
End Sub
-
-
Private Sub calMain_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles calMain.DateSelected
-
If lblControl.Text = "Start" Then
-
txtStartDate.Text = e.Start.ToShortDateString
-
Else
-
txtEndDate.Text = e.Start.ToShortDateString
-
End If
-
calMain.Visible = False
-
End Sub
Found a work around for this but would still like to know if its possible to evaluate variables.
Work Around: - Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
-
calMain.Visible = True
-
lblControl.Text = "Start"
-
End Sub
-
-
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
-
calMain.Visible = True
-
lblControl.Text = "End"
-
End Sub
-
-
Private Sub calMain_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles calMain.DateSelected
-
If lblControl.Text = "Start" Then
-
txtStartDate.Text = e.Start.ToShortDateString
-
Else
-
txtEndDate.Text = e.Start.ToShortDateString
-
End If
-
calMain.Visible = False
-
End Sub
Would this help you?
dim Hold as string
hold = sender.tostring
This did basically the same thing as the work around. - ---------------------------
-
System.Windows.Forms.Label, Text: Promotion Start Date
-
---------------------------
-
OK
-
---------------------------
-
-
---------------------------
-
System.Windows.Forms.Label, Text: Promotion End Date
-
---------------------------
-
OK
-
---------------------------
This is with the following code within each click event -
Hold = sender.ToString
-
MsgBox(Hold)
I was hoping to find something more along the lines of -
Dim SentBox as TextBox
-
SentBox.Name = lblControl.Text
Still looking for some help with this.
Still looking for some help with this.
Could you post what you'd like the output to be?
ex:
Start end
1/2/03 1/2/04
I'm not quite clear on what you want
I have two labels with two corresponding text boxes (Start Date and End Date). When clicking on one label I would like to open a calendar control. When I click on a date on the calendar control, it will send the date selected to the correct text box. So basically, is it possible to pass a control name into a variable then evaluate it to verify that it is a control and use it as such. - Public Class Form1
-
Private Sub lblStartDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblStartDate.Click
-
'Has corresponding txtStartDate
-
calMain.Visible = True
-
End Sub
-
-
Private Sub lblEndDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblEndDate.Click
-
'Has corresponding txtEndDate
-
calMain.Visible = True
-
End Sub
-
-
Private Sub calMain_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles calMain.DateSelected
-
'Which label was clicked to pass e.Start.ToShortDateString to it's textbox?
-
End Sub
-
End Class
I worked it out and here is the code that I used to solve my dilema. -
Public Class Form1
-
Dim tBox As TextBox
-
Private Sub lblStartDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblStartDate.Click
-
calMain.Visible = True
-
tBox = txtStartDate
-
End Sub
-
-
Private Sub lblEndDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblEndDate.Click
-
calMain.Visible = True
-
tBox = txtEndDate
-
End Sub
-
-
Private Sub calMain_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles calMain.DateSelected
-
tBox.Text = e.Start.ToShortDateString
-
End Sub
-
End Class
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Son KwonNam |
last post by:
In XSLT, is this possible to get value from xml using XPath
which is in XSLT variable?
I mean XPath strings can be dynamic while XSL Transforming.
If possible, How??
Because I'm not a native English speaker, it's quite hard
to make the problem clear. Please see the following example.
|
by: Christoph Putz |
last post by:
Hi!
How can i do somewhat like saxon:evaluate in my xslt transformation?
I tried to write an extension object, but in my case i need some
context information (the value of an xslt-variable) to evaluate the
xpath expression.
Is there a way to get some context information into an extension
object?
|
by: MLH |
last post by:
I've read some posts indicating that having tons of GV's in
an Access app is a bad idea. Personally, I love GVs and I
use them (possibly abuse them) all the time for everything
imaginable - have been for years. If the machine has memory
to spare and windows can use it - I'm thinking "Why not?"
I was wondering what some of you have to say about that,
particularly any severe "gotchas" you've had the unfortunate
experience to contend with.
|
by: Randall Arnold |
last post by:
I'm creating a VB 2005 Express app that hosts the webbrowser control. Everything works well except one area: the Navigating event.
In that event, I need to evaluate the URL property of the webbrowser object. The URL is set beforehand in the browser object. I'm using Webbrowser1.URL.ToString to check it. However, I get the following error when I try this:
"A first chance exception of type 'System.NullReferenceException' occurred in (my...
|
by: Dave Calkins |
last post by:
I have a native Win32 C++ app built with Visual Studio 2005. I'd like to
make use of a property grid control in this app. For an example of this, in
Visual Studio, see the properties control (select something in a dialog from
the dialog editor or a class from the class list and hit F4).
I used Spy++, which revealed that the window class of the property grid
control used by Visual Studio is "WindowsForms10.Window.8.app.0.378734a".
So,...
| |
by: shellon |
last post by:
Hi all:
I met a problem when using document.evaluate() to get text content
using XPath,
my code is as follows:
nodes = document.evaluate("/html/body/div/ul/li", document,
null,XPathResult. UNORDERED_NODE_SNAPSHOT_TYPE , null);
in the XPath expression "/html/body/div/ul/li", I need to
traverse from li to li,
|
by: Les Caudle |
last post by:
I've got a .NET 2.0 app that works quite well on all of my test boxes.
However, at the client's site, it crashes with
'has encounted a problem' basic dialog. No useful info.
I've yet to see a .NET app crash like this, without the verbose dialog that will
tell me the line # of the problem (the app was compiled in debug mode).
What steps can I take to track this down?
|
by: =?Utf-8?B?YW5rMmdv?= |
last post by:
Hi,
Thanks in advance for reading this.
Not sure where to post this question, but I hope someone in here can help.
Trying to write to Event Log in VS 2005 (.NET 2.0) using Enterprise Library
2.0
on a XP Pro SP2 Machine
|
by: John |
last post by:
Hi
I have a string expression which is evaluated based on value of a variable
like this;
"MyTable.MyField = (" & MyVar.ToString & ")"
I need to save this expression as app setting so I can change it without
having to recompile and reinstall the app every time. How do I do this?
Creating and app setting say X as "MyTable.MyField = (" & MyVar.ToString &
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |