Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. This must be too simple - but . . .

This must be too simple - but . . .

Scheduled Pinned Locked Moved Visual Basic
helpcsharpvisual-studio
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rfrank5356
    wrote on last edited by
    #1

    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 !

    G C R 3 Replies Last reply
    0
    • R rfrank5356

      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 !

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      What you have tried to do is to convert the entire control into a number, which is impossible. You have to take the value of the Text property and convert to a number, preferrably by using Decimal.Parse or Decimal.TryParse.

      --- Year happy = new Year(2007);

      1 Reply Last reply
      0
      • R rfrank5356

        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 !

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • R rfrank5356

          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 !

          R Offline
          R Offline
          rfrank5356
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups