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. Help!

Help!

Scheduled Pinned Locked Moved Visual Basic
help
5 Posts 2 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.
  • U Offline
    U Offline
    User 10694570
    wrote on last edited by
    #1

    I am trying really hard, but I'm just not getting this... This is what I need to do... Set prompt = “Enter sides of the square” Show Input Box Convert string input to length Area = length * length Set output = “Square of side length “ + length + = “: “ + area This is where I am at... Dim prompt, sideLength As String Dim area, length As Double prompt = InputBox("Enter sides of the square.") sideLength = Convert.ToDouble(length) area = length * length Me.lblOutput.Text = "Square of side length " & length & ": " & area

    L 2 Replies Last reply
    0
    • U User 10694570

      I am trying really hard, but I'm just not getting this... This is what I need to do... Set prompt = “Enter sides of the square” Show Input Box Convert string input to length Area = length * length Set output = “Square of side length “ + length + = “: “ + area This is where I am at... Dim prompt, sideLength As String Dim area, length As Double prompt = InputBox("Enter sides of the square.") sideLength = Convert.ToDouble(length) area = length * length Me.lblOutput.Text = "Square of side length " & length & ": " & area

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Member 10728667 wrote:

      sideLength = Convert.ToDouble(length)

      Where are you magically setting the value of "length"? Then you take the trouble of converting "length" to Double but then never use it. Learning to use the debugger is a very valuable skill.

      U 1 Reply Last reply
      0
      • L Lost User

        Member 10728667 wrote:

        sideLength = Convert.ToDouble(length)

        Where are you magically setting the value of "length"? Then you take the trouble of converting "length" to Double but then never use it. Learning to use the debugger is a very valuable skill.

        U Offline
        U Offline
        User 10694570
        wrote on last edited by
        #3

        Excuse me. I don't understand. I'm just learning this all, and it's very confusing. :(

        L 1 Reply Last reply
        0
        • U User 10694570

          Excuse me. I don't understand. I'm just learning this all, and it's very confusing. :(

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Edited. Misread the code. length is actual declared as a double. We can't possibly know what is confusing you unless you tell us. You are trying to convert a string to a double right? The string you are trying to convert is named "length" right? Look at your code and see if you can find anywhere in your code where you are setting "length" to be something other than an empty string.... Your code as it stands right now is you are trying to convert length (which is a double) to a double. Then put that result in a string named "sideLength". Why would you convert a double to a double? Does it make more sense to you to convert the user input to a double? Then you take the result of your convert operation and put that into a variable named "sideLength", then you don't use it anywhere. Learn to use the debugger and you can follow the code and see what it is doing.

          1 Reply Last reply
          0
          • U User 10694570

            I am trying really hard, but I'm just not getting this... This is what I need to do... Set prompt = “Enter sides of the square” Show Input Box Convert string input to length Area = length * length Set output = “Square of side length “ + length + = “: “ + area This is where I am at... Dim prompt, sideLength As String Dim area, length As Double prompt = InputBox("Enter sides of the square.") sideLength = Convert.ToDouble(length) area = length * length Me.lblOutput.Text = "Square of side length " & length & ": " & area

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Dim prompt, sideLength As String
            Dim area, length As Double

            prompt = InputBox("Enter sides of the square.")
            ' On return from this method, "prompt" will contain the value typed by the user
            ' so that is the string that needs to be converted to a number.

            sideLength = Convert.ToDouble(length)
            ' You are trying to convert the variable "length" to a number,
            ' but you have not done anything to get a value into it.
            ' You have also declared "sideLength" as a string, but now
            ' you are trying to store a Double value into it.

            area = length * length
            Me.lblOutput.Text = "Square of side length " & length & ": " & area

            Take a look at http://msdn.microsoft.com/en-GB/library/6z0ak68w(v=vs.90).aspx[^] for an example of how to use the InputBox method.

            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