5 Replies - 3449 Views - Last Post: 15 August 2009 - 06:41 PM Rate Topic: -----

#1 jinjah  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 28-July 09

patient Weight Converter

Posted 04 August 2009 - 08:49 PM

So I am trying to wirte a program and I dont even know where to begin. I am trying to make a program where you enter the persons weight then pick (from radio buttons) "convert Pounds to kilograms" or "convert kilograms to pounds" and then it should conver tthe weight when you click display weight button to display the converted weight value.
Any ideas?
Thanks :)

Is This A Good Question/Topic? 0
  • +

Replies To: patient Weight Converter

#2 PDUNZ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 376
  • Joined: 17-July 09

Re: patient Weight Converter

Posted 04 August 2009 - 09:03 PM

I would use a "Select Case" or "If" statements to see which option is checked then do the appropiate conversion.

You also need a textbox or a NumericUpDown control for enter weight, and a label or textbox to show the result.

To start off, add a text box for input (or NumericUpDown control), a label or another textbox for the result, a button, and then code the Math in the Buttonclick event to start with, and then once one conversion is working - then start adding radio buttons etc.
Was This Post Helpful? 0
  • +
  • -

#3 jinjah  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 28-July 09

Re: patient Weight Converter

Posted 15 August 2009 - 10:12 AM

I need help on how to get started to do this..an example code of some sort or something?
Was This Post Helpful? 0
  • +
  • -

#4 jinjah  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 28-July 09

Re: patient Weight Converter

Posted 15 August 2009 - 10:39 AM

  ' The btnCalculate event handler calculates the estimated const
		' of cabinets based on the linear feet and the wood type.

		'Declaration Section
		Dim decEnterWeight As Decimal
		Dim decKiloToPounds As Decimal
		Dim decPoundstoKilo As Decimal
		Dim decCostEstimate As Decimal
		Dim decConvertToKilo As Decimal = 150D
		Dim decConvertToPounds As Decimal = 250D

		' Did user enter a numeric value?
		If IsNumeric(Me.txtEnterWeight.Text) Then
			decEnterWeight = Convert.ToDecimal(Me.txtEnterWeight.Text)

			'Is Linear feet greather than zero
			If decEnterWeight > 0 Then

				' Determine conversion, Pounds to Kilo or Kilo to Pounds
				If Me.radConvertToPounds.Checked Then
					decKiloToPounds = decConvertToPounds
				ElseIf Me.radConvertToKilo.Checked Then
					decPoundstoKilo = decConvertToKilo

				End If
				' Calculate and display the cost estimate
				decCostEstimate = decEnterWeight * decConvertToPounds
				Me.lblConvertedWeight.Text = decCostEstimate.ToString("C")
			Else
				' Display error messafe if user entered a negative value
				MsgBox("You entered " & decEnterWeight.ToString() & _
					". Enter a Number Greater Than Zero. ", , "Input Error")
				Me.txtEnterWeight.Text = ""
				Me.txtEnterWeight.Focus()
			End If
		Else
			'Display error message id user entered a nonnumeric value
			MsgBox("Enter Weight, ", , "Input Error")
			Me.txtEnterWeight.Text = ""
			Me.txtEnterWeight.Focus()
		End If



i actually came up with a code now but when i enter the value into the enter weight section and put convert pounds to kilograms it doesnt come up with a value and when i put convert kilograms to pounds it comes up with a high value like "35,000.00" when i only enter 120 as a weight?

Where am i going wrong in my code?
Was This Post Helpful? 0
  • +
  • -

#5 Jay93  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 93
  • Joined: 04-August 09

Re: patient Weight Converter

Posted 15 August 2009 - 12:44 PM

It doesnt work because you've copy and pasted the code. Unless you've changed your mind from a weight conversion program to something that calculates the cost of wood.

Quote

 ' The btnCalculate event handler calculates the estimated const
		' of cabinets based on the linear feet and the wood type.


Was This Post Helpful? 0
  • +
  • -

#6 PDUNZ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 376
  • Joined: 17-July 09

Re: patient Weight Converter

Posted 15 August 2009 - 06:41 PM

That code is not really suitable, since it seems it is for wood.

Ill give you a start on converting kg to lbs.
result = Convert.ToString(input * 2.20462262). Input is the number that is entered, result is the result after the calculation.

This post has been edited by PDUNZ: 15 August 2009 - 06:42 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1