'Declarations
Private Sub CommandButton2_Click()
Dim inputValue As Double
Dim unitType As String
Dim result As Double
Dim UserResponse As Long
Dim nconntors As Double
Dim nsplices As Double
Dim ConnectLoss As Double
Dim SpliceLoss As Double
Dim MaxAttn As Double
result = 0
nconntors = 0
nsplices = 0
MaxAttn = 0
AttnCoeff = 0
Would like to do this in a From to input in the underlying Sheet, not too sure how to do it in Excel. I know how in Access
inputValue = Application.InputBox("Enter the distance value to convert:", "Input Value", Type:=1)
' Prompt user to select the unit type
unitType = InputBox("Enter the unit type in LCase (meters, feet, or kilometers):", "Unit Selection")
nconntors = Application.InputBox("Enter the Number of Connectors", "Input Value", Type:=1)
ConnectLoss = Application.InputBox("Enter TIA/EIA Connector Loss:", "Input Value", Type:=1)
nsplices = Application.InputBox("Enter the Number of Splices:", "Input Value", Type:=1)
SpliceLoss = Application.InputBox("Enter TIA/EIA Splice loss per Splice:", "Input Value", Type:=1)
AttnCoeff = Application.InputBox("Enter the Attenuation Coefficient:", "Input Value", Type:=1)
calc:s here
Select Case LCase(unitType)
Case "meters"
'result = inputValue / 1000 ' Convert meters to Kilometers
' result = Application.Convert(inputValue, "m", "km")
result = Application.WorksheetFunction.Convert(inputValue, "m", "km")
Case "feet"
'result = inputValue * 0.000304801 ' Convert feet to Kilometers
'result = Application.Convert(inputValue, "ft", "km")
result = Application.WorksheetFunction.Convert(inputValue, "ft", "km")
Case "kilometers"
result = inputValue ' Already in kilometers
'result = Application.Convert(inputValue, "km", "km")
result = Application.WorksheetFunction.Convert(inputValue, "km", "km")
MsgBox "Excuse Me Doc !...The Distance is Already in Kilometers : " & result, vbInformation, "Conversion Result"
MsgBox "I am Done !", vbExclamation
GoTo AfterSelect ' Exit the Select Case block
Doing a Display in a message box of the reults
MaxAttn = (nconntors * ConnectLoss) + (nsplices * SpliceLoss) + (AttnCoeff * result)
Unload UserForm1
MsgBox "The distance in kilometers is: " & result & vbCrLf & _
"The Maximum Insertion Loss (Attenuation) is: " & MaxAttn & " dB/km" & vbCrLf & _
"The Attenuation coefficient is: " & AttnCoeff & vbCrLf & _
"The Connector loss is: " & ConnectLoss * 2 & vbCrLf & _
"The Splice Loss is: " & SpliceLoss * nsplices, vbInformation, "Maximum dB/Km Loss"
Basically converting a value from Feet to Kilometers
Adding Number of splices * Splice loss factor
Adding Number of connectors * Connector loss Factor
Summing all up to get Attenuation Value (which is MaxAttn)
first 3 to 4v digits after the floating point are okay then they are off, I don't think it is rounding, but my head is tired
Thanks for your time
Private Sub CommandButton2_Click()
Dim inputValue As Double
Dim unitType As String
Dim result As Double
Dim UserResponse As Long
Dim nconntors As Double
Dim nsplices As Double
Dim ConnectLoss As Double
Dim SpliceLoss As Double
Dim MaxAttn As Double
result = 0
nconntors = 0
nsplices = 0
MaxAttn = 0
AttnCoeff = 0
Would like to do this in a From to input in the underlying Sheet, not too sure how to do it in Excel. I know how in Access
inputValue = Application.InputBox("Enter the distance value to convert:", "Input Value", Type:=1)
' Prompt user to select the unit type
unitType = InputBox("Enter the unit type in LCase (meters, feet, or kilometers):", "Unit Selection")
nconntors = Application.InputBox("Enter the Number of Connectors", "Input Value", Type:=1)
ConnectLoss = Application.InputBox("Enter TIA/EIA Connector Loss:", "Input Value", Type:=1)
nsplices = Application.InputBox("Enter the Number of Splices:", "Input Value", Type:=1)
SpliceLoss = Application.InputBox("Enter TIA/EIA Splice loss per Splice:", "Input Value", Type:=1)
AttnCoeff = Application.InputBox("Enter the Attenuation Coefficient:", "Input Value", Type:=1)
calc:s here
Select Case LCase(unitType)
Case "meters"
'result = inputValue / 1000 ' Convert meters to Kilometers
' result = Application.Convert(inputValue, "m", "km")
result = Application.WorksheetFunction.Convert(inputValue, "m", "km")
Case "feet"
'result = inputValue * 0.000304801 ' Convert feet to Kilometers
'result = Application.Convert(inputValue, "ft", "km")
result = Application.WorksheetFunction.Convert(inputValue, "ft", "km")
Case "kilometers"
result = inputValue ' Already in kilometers
'result = Application.Convert(inputValue, "km", "km")
result = Application.WorksheetFunction.Convert(inputValue, "km", "km")
MsgBox "Excuse Me Doc !...The Distance is Already in Kilometers : " & result, vbInformation, "Conversion Result"
MsgBox "I am Done !", vbExclamation
GoTo AfterSelect ' Exit the Select Case block
Doing a Display in a message box of the reults
MaxAttn = (nconntors * ConnectLoss) + (nsplices * SpliceLoss) + (AttnCoeff * result)
Unload UserForm1
MsgBox "The distance in kilometers is: " & result & vbCrLf & _
"The Maximum Insertion Loss (Attenuation) is: " & MaxAttn & " dB/km" & vbCrLf & _
"The Attenuation coefficient is: " & AttnCoeff & vbCrLf & _
"The Connector loss is: " & ConnectLoss * 2 & vbCrLf & _
"The Splice Loss is: " & SpliceLoss * nsplices, vbInformation, "Maximum dB/Km Loss"
Basically converting a value from Feet to Kilometers
Adding Number of splices * Splice loss factor
Adding Number of connectors * Connector loss Factor
Summing all up to get Attenuation Value (which is MaxAttn)
first 3 to 4v digits after the floating point are okay then they are off, I don't think it is rounding, but my head is tired
Thanks for your time