|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Add to a user inputted datewith 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! Hello bryan.a.fow***@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 Show quoteHide quote > 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 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: Show quoteHide quote > Hello bryan.a.fow***@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
Get Application EXE name in VS.2005
Speed in VB 2005 Textbox LostFocus event fires after Command Button's OnClick event About Adding controls dynamically VB6 and ms SQL 2005 DATETIME Messagebox Issue Variable function activation select stmt Delay in making control visible when connecting to database Sending an e-mail on a wireless network |
|||||||||||||||||||||||