Here is the repaired code with your math fix in thanks for your help, :) sorry about the confusion.:oops:
Dim ALT_IN As Long
Dim dwResult2 As Long
'NOTICE THE TWO ARE ON SEPERATE LINES, IF YOU
'COMBINE SOMETIMES VB DOES NOT GIVE YOU REAL LONGS
'TWO POSITION ENCODER
If WHICHWAY = 2 Then
If EncoderDisplacement = 1 Then
'DEC ALT
Call FSUIPC_Read(&H7D4, 4, VarPtr(ALT_IN), dwResult2)
Call FSUIPC_Process((dwResult2))
ALT_OUT = PROCESS_ALT((ALT_IN), False)
'CANT HAVE A NEG ALT
If ALT_OUT <= 150 Then ALT_OUT = 0
Call FSUIPC_Write(&H7D4, 4, VarPtr(ALT_OUT), (dwResult2))
Call FSUIPC_Process((dwResult2))
End If
If EncoderDisplacement = -1 Then
'INC ALT
Call FSUIPC_Read(&H7D4, 4, VarPtr(ALT_IN), dwResult2)
Call FSUIPC_Process((dwResult2))
ALT_OUT = PROCESS_ALT((ALT_IN), True)
'FS TAKES CARE OF MAX ALT FROM WHAT I HAVE SEEN
Call FSUIPC_Write(&H7D4, 4, VarPtr(ALT_OUT), (dwResult2))
Call FSUIPC_Process((dwResult2))
End If
End If
End Sub
Function PROCESS_ALT(INVAL As Long, ADDALT As Boolean) As Long
Dim LOCAL_PROC As Long
LOCAL_PROC = Round(((CCur(INVAL) * 328084) / 65536) / 100000, 0)
'VB HAS ISSUES WITH LONGS AND MULTIPLYING DONT ASK ME IT JUST DOES
If Not ADDALT Then
INVAL = LOCAL_PROC - 100#
Else
INVAL = LOCAL_PROC + 100#
End If
If INVAL = 0 Then Exit Function
'CHECK FOR 0 FIRST, DOING DIVISION AND HATE THAT DIVIDE BY ZERO ERROR
'WHICH WAY ARE WE GOING UP OR DOWN NOTICE THIS HANDLES INC BY 100
ROUND_OFF_ERROR = Fix(INVAL / 1000)
If ROUND_OFF_ERROR < 10 Then ROUND_OFF_ERROR = 10
'DONT KNOW WHY BUT WHEN I FEED JUST THE NUMBER IN I GET ROUND OFF
'BY FS SO I START WITH 10 AND WORK MY WAY UP, CHECKED
'ALL THE WAY THRU HOWEVER YOUR RESULTS MAY DIFFER SO CHECK MY MATH
PROCESS_ALT = ((INVAL * 65536#) / 3.28084) + ROUND_OFF_ERROR
'FEED IT BACK AN POST TO THE OFFSET.
End Function
Thanks once again Pete