Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using DB screen field values in Calculations

Status
Not open for further replies.

mushin

Programmer
Oct 4, 2000
49
I'm a bit new to .Net and am perplexed by some unwarranted
complexity.

dim d as datetime
dim dur as int

d = datetimepickr1.value.
datetimepicker2.value = d.addminutes(30).

This works ok, but now I want to use the contents on myField
in place of the hard coded value of 30.

I have a db field (myField) of type INT.
On my Screen I display myField.text.

When I change the value a calculation occurs with a date.

datetimepicker2.value = d.addminutes(myField).

I have tried to convert myField to an int but the calc still
protests.

dim Dur as int32
dur = convert.toint32(myField.text)
datetimepicker2.value = d.addminutes(myField).

error *** "input string was not in correct format"

I tried this as a 'double' to no avail.......

What gives ? Anyone ?


 
If I turn 'option Stict' off

I can perform my calcs just fine,
so It is just a conversion issue.
????
 
Ok, Ignore me today......

The conversion works as in :

Dim d As DateTime
Dim myDur As Double

If tbDuration.Text > " " Then
d = DateTimePicker1.Value
myDur = Convert.ToDouble(tbDuration.Text)
DateTimePicker2.Value = d.AddMinutes(myDur)
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top