Alessandro Giraldi
New member
- Local time
- Today, 04:38
- Joined
- Feb 24, 2020
- Messages
- 15
ok now is correct
tk u so much...
grazie 1000000
Public Function GetOrdito(strOrdito As String) As t_Ordito
Dim Ordito As t_Ordito
Dim character As String
Dim strnumberBefore As String
Dim numberBefore As Integer
Dim distributeNumber As Integer
Dim distribute As Boolean
Dim i As Integer
distributeNumber = 1
For i = 1 To Len(strOrdito)
character = mID(strOrdito, i, 1)
Debug.Print "Char in beginning" & character
If IsNumeric(character) Then
strnumberBefore = strnumberBefore & character
numberBefore = CInt(strnumberBefore)
Else
If distribute = False Then
' distributeNumber = 1
' Else
distributeNumber = numberBefore
End If
' Debug.Print "Char " & character & "Distribute " & distribute & " number " & distributeNumber & " Number before " & numberBefore
Select Case character
Case "A"
Ordito.A = Ordito.A + numberBefore * distributeNumber
Debug.Print Ordito.A & " A"
strnumberBefore = ""
Case "B"
Ordito.B = Ordito.B + numberBefore * distributeNumber
strnumberBefore = ""
Case "C"
Ordito.C = Ordito.C + numberBefore * distributeNumber
strnumberBefore = ""
Case "D"
Ordito.D = Ordito.D + numberBefore * distributeNumber
strnumberBefore = ""
Case "E"
Ordito.E = Ordito.E + numberBefore * distributeNumber
strnumberBefore = ""
Case "("
distribute = True
distribute = numberBefore
strnumberBefore = ""
Case ")"
distribute = False
distributeNumber = 1
strnumberBefore = ""
End Select
End If
Next i
Ordito.Total = Ordito.A + Ordito.B + Ordito.C + Ordito.D + Ordito.E
GetOrdito = Ordito
End Function
tk u so much...
grazie 1000000
Public Function GetOrdito(strOrdito As String) As t_Ordito
Dim Ordito As t_Ordito
Dim character As String
Dim strnumberBefore As String
Dim numberBefore As Integer
Dim distributeNumber As Integer
Dim distribute As Boolean
Dim i As Integer
distributeNumber = 1
For i = 1 To Len(strOrdito)
character = mID(strOrdito, i, 1)
Debug.Print "Char in beginning" & character
If IsNumeric(character) Then
strnumberBefore = strnumberBefore & character
numberBefore = CInt(strnumberBefore)
Else
If distribute = False Then
' distributeNumber = 1
' Else
distributeNumber = numberBefore
End If
' Debug.Print "Char " & character & "Distribute " & distribute & " number " & distributeNumber & " Number before " & numberBefore
Select Case character
Case "A"
Ordito.A = Ordito.A + numberBefore * distributeNumber
Debug.Print Ordito.A & " A"
strnumberBefore = ""
Case "B"
Ordito.B = Ordito.B + numberBefore * distributeNumber
strnumberBefore = ""
Case "C"
Ordito.C = Ordito.C + numberBefore * distributeNumber
strnumberBefore = ""
Case "D"
Ordito.D = Ordito.D + numberBefore * distributeNumber
strnumberBefore = ""
Case "E"
Ordito.E = Ordito.E + numberBefore * distributeNumber
strnumberBefore = ""
Case "("
distribute = True
distribute = numberBefore
strnumberBefore = ""
Case ")"
distribute = False
distributeNumber = 1
strnumberBefore = ""
End Select
End If
Next i
Ordito.Total = Ordito.A + Ordito.B + Ordito.C + Ordito.D + Ordito.E
GetOrdito = Ordito
End Function