-
After some more research I finally found a way to calculate Location with a math function, instead of using 47 Select Case steps
Below are the 2 procedures that allow me to correctly calculate the location based on any number provided. It also returns the value as a String (since leading zeros are required by Astra for this txt file).
[vba]Function Ceiling(Number As Double) As Long
Ceiling = -Int(-Number)
End Function
Sub LocationCount(XStart As Integer, Section As String)
Dim i As Integer
i = XStart
If Ceiling((i - 1) / 3) = ((i - 1) / 3) Then
If Len(CStr(i)) = 1 Then
Section = "00" & i
ElseIf Len(CStr(i)) = 2 Then
Section = "0" & i
End If
ElseIf Ceiling((i - 2) / 3) = ((i - 2) / 3) Then
If Len(CStr(i)) = 1 Then
Section = "00" & i-1
ElseIf Len(CStr(i)) = 2 Then
Section = "0" & i-1
End If
Else
If Len(CStr(i)) = 1 Then
Section = "00" & i-2
ElseIf Len(CStr(i)) = 2 Then
Section = "0" & i-2
End If
End If
End Sub[/vba]
Astra, I've attached a new version of the RackForms database that incorporates this new procedure into the Location setup. What this means is that you can calculate the number of any Location you want, no matter what X-coor you use. This also means that you won't have to write more Select Case steps if you want to calculate Locations above X-coor 139.
Last edited by CreganTur; 06-20-2008 at 08:56 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules