PLC3 BCD to Decimal iFIX3.5


Thread Starter


1775 GA Script contains an FR which converts the BCD to binary but VBA does not support this function. How would I do the FR conversion to have decimal equivalents to use in VBA?

Smith, James

<p>Try this to convert binary to decimal:
Private Sub Command1_Click()
Dim i As Long, x As Double, bin As String
maxpower = Len(Text1.Text)

x = Val(Text1.Text)

For i = 1 To maxpower Step 1
x = Mid(Text1.Text, i, 1)
If x = 1 Then
b = b + (2 ^ (maxpower - i))
End If
Text2.Text = b
End Sub
<p>Text1 is the binary number and text2 is the decimal number.


<p>James Smith<br>
Automation Department<br>
American Castings LLC<br>
Pryor Oklahoma<br>
918-476-4391 V.<br>
918-476-4321 F.