This must be too simple - but . . .
-
HI I am building a camera control app - I am getting Error 3 Value of type 'System.Windows.Forms.TextBox' cannot be converted to 'Decimal'. C:\Documents and Settings\Compaq_Owner\My Documents\Visual Studio 2005\Projects\CameraControlV1\CameraControlV1\Form1.vb 288 25 CameraControlV1 I have a field defined on a form as a textbox (no mask)but I could change it to a masked box Private Sub AltitudeAGL_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AltitudeAGL.TextChanged AltitudeAGLIn = AltitudeAGL End Sub I want to move this into the following variable and use for calculations . . . Dim AltitudeAGLIn As Decimal = 0 So I can use it in the following where all variables are dim'ed as Decimal Private Sub CalculateAngularVelocity(ByVal GPSSpeedIn As Integer, ByVal AltitudeAGLIn As Integer) 'This uses a HP9100 encoder, 500 counts per motor revolution, 303.366 counts per degree 'Formula W (Rads per sec) = V (Ft Per sec) / R (Ft) Dim CountsPerRad As Decimal = 17379.79D GroundVelocity = GPSSpeedIn * FeetPerNauticalMile * SecondsPerHour AngularVelocity = Decimal.Divide(GroundVelocity, AltitudeAGLIn) CountRate = AngularVelocity * CountsPerRad End Sub As I said - this must be simple - but the Visual Studio help system is not helping !
-
HI I am building a camera control app - I am getting Error 3 Value of type 'System.Windows.Forms.TextBox' cannot be converted to 'Decimal'. C:\Documents and Settings\Compaq_Owner\My Documents\Visual Studio 2005\Projects\CameraControlV1\CameraControlV1\Form1.vb 288 25 CameraControlV1 I have a field defined on a form as a textbox (no mask)but I could change it to a masked box Private Sub AltitudeAGL_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AltitudeAGL.TextChanged AltitudeAGLIn = AltitudeAGL End Sub I want to move this into the following variable and use for calculations . . . Dim AltitudeAGLIn As Decimal = 0 So I can use it in the following where all variables are dim'ed as Decimal Private Sub CalculateAngularVelocity(ByVal GPSSpeedIn As Integer, ByVal AltitudeAGLIn As Integer) 'This uses a HP9100 encoder, 500 counts per motor revolution, 303.366 counts per degree 'Formula W (Rads per sec) = V (Ft Per sec) / R (Ft) Dim CountsPerRad As Decimal = 17379.79D GroundVelocity = GPSSpeedIn * FeetPerNauticalMile * SecondsPerHour AngularVelocity = Decimal.Divide(GroundVelocity, AltitudeAGLIn) CountRate = AngularVelocity * CountsPerRad End Sub As I said - this must be simple - but the Visual Studio help system is not helping !
-
HI I am building a camera control app - I am getting Error 3 Value of type 'System.Windows.Forms.TextBox' cannot be converted to 'Decimal'. C:\Documents and Settings\Compaq_Owner\My Documents\Visual Studio 2005\Projects\CameraControlV1\CameraControlV1\Form1.vb 288 25 CameraControlV1 I have a field defined on a form as a textbox (no mask)but I could change it to a masked box Private Sub AltitudeAGL_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AltitudeAGL.TextChanged AltitudeAGLIn = AltitudeAGL End Sub I want to move this into the following variable and use for calculations . . . Dim AltitudeAGLIn As Decimal = 0 So I can use it in the following where all variables are dim'ed as Decimal Private Sub CalculateAngularVelocity(ByVal GPSSpeedIn As Integer, ByVal AltitudeAGLIn As Integer) 'This uses a HP9100 encoder, 500 counts per motor revolution, 303.366 counts per degree 'Formula W (Rads per sec) = V (Ft Per sec) / R (Ft) Dim CountsPerRad As Decimal = 17379.79D GroundVelocity = GPSSpeedIn * FeetPerNauticalMile * SecondsPerHour AngularVelocity = Decimal.Divide(GroundVelocity, AltitudeAGLIn) CountRate = AngularVelocity * CountsPerRad End Sub As I said - this must be simple - but the Visual Studio help system is not helping !
What camera are you controlling ? You should use Decimal.TryPArse, it returns false if the value can't be converted.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
-
HI I am building a camera control app - I am getting Error 3 Value of type 'System.Windows.Forms.TextBox' cannot be converted to 'Decimal'. C:\Documents and Settings\Compaq_Owner\My Documents\Visual Studio 2005\Projects\CameraControlV1\CameraControlV1\Form1.vb 288 25 CameraControlV1 I have a field defined on a form as a textbox (no mask)but I could change it to a masked box Private Sub AltitudeAGL_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AltitudeAGL.TextChanged AltitudeAGLIn = AltitudeAGL End Sub I want to move this into the following variable and use for calculations . . . Dim AltitudeAGLIn As Decimal = 0 So I can use it in the following where all variables are dim'ed as Decimal Private Sub CalculateAngularVelocity(ByVal GPSSpeedIn As Integer, ByVal AltitudeAGLIn As Integer) 'This uses a HP9100 encoder, 500 counts per motor revolution, 303.366 counts per degree 'Formula W (Rads per sec) = V (Ft Per sec) / R (Ft) Dim CountsPerRad As Decimal = 17379.79D GroundVelocity = GPSSpeedIn * FeetPerNauticalMile * SecondsPerHour AngularVelocity = Decimal.Divide(GroundVelocity, AltitudeAGLIn) CountRate = AngularVelocity * CountsPerRad End Sub As I said - this must be simple - but the Visual Studio help system is not helping !
Well thanks ! It took me a while but I managed to suss out the following . . . and the values are correct - I wound up declaring\f every6thing as double I am using a Canon EOS with a Canon SDK, and an Allmotion servo control and a Garmin GPS Next is to scan the com ports to get the location of the serial usb devices Any Ideas ?? Thanks Again !! bob Private Sub CalculateAngularVelocity(ByVal GPSSpeedIn As Double, ByVal AltitudeAGLIn As Double) 'This uses a HP9100 encoder, 500 counts per motor revolution, 303.366 counts per degree 'Formula W (Rads per sec) = V (Ft Per sec) / R (Ft) ConvertSuccessful = Double.TryParse(AltitudeAGL.Text, AltitudeAGLIn) If Not GPSPresent Then ConvertSuccessful = Double.TryParse(GPS_GroundSpeed.Text, GPSSpeedIn) End If GroundVelocity = GPSSpeedIn * FeetPerNauticalMile / SecondsPerHour AngularVelocity = GroundVelocity / AltitudeAGLIn MsgBox("GS " & GroundVelocity) MsgBox("alt " & AltitudeAGLIn) Dim AngularVelocityDegrees As Double AngularVelocityDegrees = Math.PI * 2 * AngularVelocity MsgBox("Angular Velocity" & AngularVelocityDegrees) CountRate = AngularVelocity * CountsPerRad MsgBox("CountRate" & CountRate) End Sub