Link to home
Start Free TrialLog in
Avatar of E=mc2
E=mc2Flag for Canada

asked on

I would like to use a script to provide calculations from kg to lbs and viceversa

I would like a script that a user can simply double click.
It should prompt them if they want to convert from lbs to kg or kg to lbs.
Depending on what is selected they enter an amount, and then the calculated amount will then be provided for them.
ASKER CERTIFIED SOLUTION
Avatar of Joe Klimis
Joe Klimis
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Joe Howard
Here is a vbs:
Sub Demo()
    Dim dblAmount
    Dim intMeasurment
    Dim dblResult
    intMeasurment = InputBox("Which measurment would you like to convert from?" & vbCrLf & vbCrLf & "For ''lbs to kg'' type 1" & vbCrLf & "For ''kg to lbs'' type 2", "Measurment Conversion")
    dblAmount = InputBox("Please enter the weight to convert.", "Measurment Conversion")
    dblResult = (IIf(intMeasurment = 1, dblAmount / 0.4535922921969, dblAmount * 2.204623))
    MsgBox dblResult
End Sub

Open in new window

Avatar of E=mc2

ASKER

@joeklimis - Is your script a batch script, Powershell or VBScript?
Hi
this is a Powershell script , wich uses .net forms

just save it into a file and run it in the normal way  

Joe
Avatar of E=mc2

ASKER

@MacroShadow - when trying to run the script nothing happens.
try adding   Demo()  as the last line to invoke the subroutine, you may not need the ()
Avatar of E=mc2

ASKER

Joe are you referring to the script from MacroShadow?
Avatar of E=mc2

ASKER

@MacroShadow - I added the Demo(), however after I enter the weight to convert, it does not calculate anything..
Avatar of E=mc2

ASKER

@MacroShadow - if I try to run the script by doubleclicking the vbs file, I get an error:
Type mismatch: 'IIf'
Code:  800A000D
@100questions  - Yes I was , I am guessing this needed to be VB, its a  sham as the Powershell rocked  :-)

did you try the powershell ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of E=mc2

ASKER

Thanks everyone, both work well.