473,749 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Valu eChanged(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles DateMyPick.Valu eChanged
'----Set Variable to this value----'
MyDate = DateMyPick.Valu e

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
MyDate2 = Convert.ToDateT ime("MyDate"
CompDate = MyDate2.AddMont hs(3)
DateCompPick.Va lue = 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.FormatE xception' 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 1546
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_Valu eChanged(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles DateMyPick.Valu eChanged
'----Set Variable to this value----'
MyDate = DateMyPick.Valu e
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
MyDate2 = Convert.ToDateT ime("MyDate"
CompDate = MyDate2.AddMont hs(3)
DateCompPick.Va lue = CompDate

Aug 7 '06 #2
Thanks...

I took out the;

MyDate2 = Convert.ToDateT ime("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_Valu eChanged(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles DateMyPick.Valu eChanged
'----Set Variable to this value----'
MyDate = DateMyPick.Valu e
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
MyDate2 = Convert.ToDateT ime("MyDate"
CompDate = MyDate2.AddMont hs(3)
DateCompPick.Va lue = CompDate
Aug 8 '06 #3

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

Similar topics

13
9299
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 three dropdow boxes for hours, minutes, and AM/PM. All of these need to be considered together and converted to one Unix Timestamp and then inserted to the MYSQL date field. The type of field is INT (11) so that I can instead of the standard...
0
3481
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 script interact -nobuffer -re "(.*)\r" return I am having problems writing this in perl expect. I used the following:
9
5843
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. The user will be presented with a list of 5 selections they can make. They will then be prompted for which selection they want to enter (which can only be 1-5, no characters or anything like it). Once they select the number, 1 for Euro, 2 for...
15
5655
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 a = a + 1 %> <tr> <td> <input type=checkbox name=chkDefect value=<%=objRSDefect1("iDefectId")%>> <%=objRSDefect1("vcDefect")%> </td>
4
3512
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 that contain the user inputted text for a specific field in the query's criteria section. I want the criteria to search for any matching part of the word, for example: If the user enters in the text box: rabbit The query should return all...
5
2296
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 to pass that number along with the the SQL call. My current code is as follows: Private Sub butMoveNDStoBO_Click() On Error GoTo Err_butMoveNDStoBO_Click Dim RecordNo As Long Dim SQL As String RecordNo =...
1
1818
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 from the inputted date into individual variables then reconstruct them as a new variable into the format dd/mm/yyyy which will then be returned from the function. Would this be the best approach to create this function? If so what inbuilt function...
2
1336
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 program is to collect user information so I was wondering if it was possible to send the information to my e-mail address or somewhere else where I could possibly receive it, thank you for your help.
1
1607
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 request made by users seeking access to a software system. It has 4 combo boxes that Type of access ; values = read, edit, associate Level 1 - values = 1,2,3,4
0
8997
marktang
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...
0
9568
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, 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...
0
9389
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 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...
1
9335
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6079
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3320
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
2
2794
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2218
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.