is this right?
Dim timein1 As DateTime = CDate(TimeInTextBox.Text)
Dim timeout1 As DateTime = CDate(TimeOutTextBox.Text)
22 Replies - 1302 Views - Last Post: 11 October 2012 - 11:48 AM
#17
Re: adding time values from two textbox
Posted 11 October 2012 - 10:19 AM
or this one?
Dim SDate1 As DateTime = DateTime.Parse(TimeInTextBox.Text)
Dim SDate2 As DateTime = DateTime.Parse(TimeOutTextBox.Text)
Dim SDate1 As DateTime = DateTime.Parse(TimeInTextBox.Text)
Dim SDate2 As DateTime = DateTime.Parse(TimeOutTextBox.Text)
#18
Re: adding time values from two textbox
Posted 11 October 2012 - 10:23 AM
I would use DateTime.TryParse when getting info from textboxes.
#19
Re: adding time values from two textbox
Posted 11 October 2012 - 10:34 AM
_HAWK_, on 11 October 2012 - 10:23 AM, said:
I would use DateTime.TryParse when getting info from textboxes.
Dim SDate1 As DateTime = DateTime.TryParse(TimeInTextBox.Text)
there is an error saying overload resolution failed because no accessible 'Try Parse' accepts this number of arguments
#20
Re: adding time values from two textbox
Posted 11 October 2012 - 10:52 AM
It's asking for more arguments
But...
Tryparse returns a boolean true upon success, the parameters are what you are trying to parse and what variable do you want to use upon success.
So upon success myDate which you defined to be datetime now holds an actual date of 5/5/2012
But...
Tryparse returns a boolean true upon success, the parameters are what you are trying to parse and what variable do you want to use upon success.
Dim myDate as DateTime
If DateTime.TryParse("05/05/2012", myDate) Then
'Parse Successful do something with the variable
End if
So upon success myDate which you defined to be datetime now holds an actual date of 5/5/2012
This post has been edited by CharlieMay: 11 October 2012 - 10:52 AM
#21
Re: adding time values from two textbox
Posted 11 October 2012 - 11:03 AM
CharlieMay, on 11 October 2012 - 10:52 AM, said:
It's asking for more arguments
But...
Tryparse returns a boolean true upon success, the parameters are what you are trying to parse and what variable do you want to use upon success.
So upon success myDate which you defined to be datetime now holds an actual date of 5/5/2012
But...
Tryparse returns a boolean true upon success, the parameters are what you are trying to parse and what variable do you want to use upon success.
Dim myDate as DateTime
If DateTime.TryParse("05/05/2012", myDate) Then
'Parse Successful do something with the variable
End if
So upon success myDate which you defined to be datetime now holds an actual date of 5/5/2012
but i don't want to assign a fixed date... what happens to the textbox?
i also tried this but i didn't get the right result
Dim SDate1 As DateTime = DateTime.Parse(TimeInTextBox.Text)
Dim SDate2 As DateTime = DateTime.Parse(TimeOutTextBox.Text)
TotalOTTextBox.Text = Val(SDate1) - Val(SDate2)
TotalHWTextBox.Text = Val(SDate1) + Val(SDate2)
This post has been edited by AdamSpeight2008: 11 October 2012 - 11:39 AM
#22
Re: adding time values from two textbox
Posted 11 October 2012 - 11:17 AM
Instead of fixed date from example of CharlieMay, use .Text property of your TextBox.
#23
Re: adding time values from two textbox
Posted 11 October 2012 - 11:48 AM
jhedonghae, on 11 October 2012 - 07:03 PM, said:
Dim SDate1 As DateTime = DateTime.Parse(TimeInTextBox.Text)
Dim SDate2 As DateTime = DateTime.Parse(TimeOutTextBox.Text)
TotalOTTextBox.Text = Val(SDate1) - Val(SDate2)
TotalHWTextBox.Text = Val(SDate1) + Val(SDate2)
Why are using Val(SDate1) ? I is a date, and it has a - operator defined, to do the difference.
I think you should go back and learn the basics, and syntax. What a function is? What a type is? What an Object is? Controls and GUI are an advanced for a beginner, start with Console applications. As it focuses you on the design of the algorithm since there no controls.
|
|

New Topic/Question
Reply




MultiQuote




|