473,406 Members | 2,620 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,406 software developers and data experts.

Add to a user inputted date

I'm really new working with VB.net and I'm working on a simple program
with a date input. I've got a couple of questions;

1) I'm using a DateTimePicker to show both the user inputted date as
well as the calculated date. Is this a good way to do this or is there
an easier way?

2) I can't seem to get the code right to take the user inputted date to
output to the new calculated date. This is my code so far;

Dim MyDate As Date
Dim MyDate2 As Date
Dim CompDate As Date

Private Sub DateMyPick_ValueChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles DateMyPick.ValueChanged
'----Set Variable to this value----'
MyDate = DateMyPick.Value

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
MyDate2 = Convert.ToDateTime("MyDate"
CompDate = MyDate2.AddMonths(3)
DateCompPick.Value = CompDate

Is this about right or am I way off base? It compiles fine, but when I
go in, and actually click the button, I get an error message;

"An unhandled exception of type 'System.FormatException' occured in
mscorlib.dll Additional information: The stirng was not recognized as
a valid DateTime. There is an unknown word starting at index 0."

Any and all help would be greatly appreciated. Thanks!

Aug 7 '06 #1
2 1524
Hello br************@gmail.com,

Double-quote marks indicate a string. The string "MyDate" is not a date
in any country that I know of. Try using the variable directly.
This would eliminate the non-existant need for MyDate2.

-Boo
Dim MyDate As Date
Dim MyDate2 As Date
Dim CompDate As Date
Private Sub DateMyPick_ValueChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles DateMyPick.ValueChanged
'----Set Variable to this value----'
MyDate = DateMyPick.Value
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
MyDate2 = Convert.ToDateTime("MyDate"
CompDate = MyDate2.AddMonths(3)
DateCompPick.Value = CompDate

Aug 7 '06 #2
Thanks...

I took out the;

MyDate2 = Convert.ToDateTime("MyDate")

and I put everything back to MyDate, and it works now. Thanks a bunch!

GhostInAK wrote:
Hello br************@gmail.com,

Double-quote marks indicate a string. The string "MyDate" is not a date
in any country that I know of. Try using the variable directly.
This would eliminate the non-existant need for MyDate2.

-Boo
Dim MyDate As Date
Dim MyDate2 As Date
Dim CompDate As Date
Private Sub DateMyPick_ValueChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles DateMyPick.ValueChanged
'----Set Variable to this value----'
MyDate = DateMyPick.Value
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
MyDate2 = Convert.ToDateTime("MyDate"
CompDate = MyDate2.AddMonths(3)
DateCompPick.Value = CompDate
Aug 8 '06 #3

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

Similar topics

13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
0
by: MarkD | last post by:
In regular (tcl) expect the following code waits for the user to enter a password followed by enter and then returns to the script: expect "Password:" #ask user for password and then return to...
9
by: chuck | last post by:
I need some help with validating user input. I am writing a C computer program for an intro to C course. Here is the situation. I am creating an application that will do currency conversions. ...
15
by: intscript | last post by:
Hello Everybody I have a dynamic check box input box and I want to compute the value of the input box, in every checked box Here is my HTML code a=(-1) Do until objRSDefect1.eof or a = RecFound ...
4
waynetheengineer
by: waynetheengineer | last post by:
Hi, I was wondering if anyone had any suggestions on my database: I have a form that accepts user input into a single text box. When the OK button is hit, a query should search for all records...
5
by: OtheymAverian | last post by:
I am trying to call a stored SQL procedure while either passing or accepting a used inputted parameter. Currently I have a variable coded to accept the number I need to pass, but I do not know how...
1
by: tfrancis | last post by:
Hi all, I'm attempting to write a basic db2 function that converts the format of an inputted date of yyyymmddhhmm to dd/mm/yyyy. (DB2 8.1 on windows) My approach was to strip the characters...
2
by: frank1730 | last post by:
Hi all, I have created a program on vb 2005 where the user can input their information into 2 textboxes and then submit the information by clicking on a button under the text boxes. The idea of this...
1
by: jay123987 | last post by:
Happy new year all - hope you had a great one! I am kind of stuck in regards to creating a particular function on a form. I currently have a form that allows the operator to insert details or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...

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.