Wrox Programmer Forums
|
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 April 7th, 2006, 09:11 AM
Authorized User
 
Join Date: Mar 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default DateTimePicker with Two Forms

I have a simple problem that is driving me crazy.
On Form1 I have a dateTimePicker
However when the user opens Form2, the value property does not change.

here is some code:

Public Class Form2
    Inherits System.Windows.Forms.Form
    Dim myForm1 As Form1


#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()
        Me.myForm1 = New Form1



        'This call is required by the Windows Form Designer.
        InitializeComponent()
        radioButtons(0) = RadioButton1
        radioButtons(1) = RadioButton2

        'Add any initialization after the InitializeComponent() call

    End Sub

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

     dateOf = Format(myForm1.DatePicker.Value, "MM/dd/yyyy")'this only returns today's date

         myForm1.Patient(doc, patID, vID, svc, cat, dMy, hMs)


    End Sub

can somebody tell me the way to get the changed value of the datetimepicker.value


 
Old April 8th, 2006, 12:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Your instantiating a new Form1 when you load Form2 so you would be grabbing the value from the new Form1 and not the original.

You can do this a couple of ways. You can either declare the datetimepicker as a shared variable and then access it from the second form (there are several examples of this in this forum) or you can overload the constructor in the 2nd form, passing the parent form so that you can access it.

J
 
Old April 10th, 2006, 03:32 PM
Authorized User
 
Join Date: Mar 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply Katsarosj, I knew I was instantiating a new Form1, but couldn't figure out how to get the value from the original. For now I am just using a public variable in my class. But that leads me to another Question... I'll put it in a new topic though.






Similar Threads
Thread Thread Starter Forum Replies Last Post
nullable datetimepicker.value Anar Visual Studio 2005 2 January 4th, 2010 04:29 PM
C++ Builder 6 - DateTimePicker rowin C++ Programming 0 April 28th, 2006 08:54 AM
dateTimePicker sconineuk General .NET 0 March 7th, 2006 11:22 AM
DateTimePicker validating fongklem VS.NET 2002/2003 0 July 20th, 2005 09:17 AM
Strange behavior of DateTimePicker? wwz VS.NET 2002/2003 0 February 19th, 2004 06:56 AM





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