Ajde da pokusam da prevedem na brzaka (onko malo pijan :) )
Uputio te je na ovo:
Code:
Public Function KontrolniBroj(ByVal inModel As Variant, ByVal inTekst As String) As String
Dim varInput_Value As Variant
Dim varResult As Variant
KontrolniBroj = ""
If inTekst = "" Then Exit Function
ObradiTekst inTekst
If Not IsNumeric(inTekst) Then Exit Function
varInput_Value = CDec(inTekst) * 100
varResult = CDec((varInput_Value / inModel) - Fix(varInput_Value / inModel))
varResult = Round(varResult, 2)
varResult = inModel + 1 - Round(varResult * inModel)
KontrolniBroj = CStr(varResult)
If Len(KontrolniBroj) = 1 Then
KontrolniBroj = "0" & KontrolniBroj
End If
End Function
Private Sub ObradiTekst(ByRef inTekst As String)
Dim Slova
Dim Vrednosti
Dim intBrojac As Integer
Dim intBrojac2 As Integer
Dim strTMP As String
inTekst = UCase(inTekst)
strTMP = ""
Slova = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", _
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", _
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", _
"U", "V", "W", "X", "Y", "Z")
Vrednosti = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", _
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19", _
"20", "21", "22", "23", "24", "25", "26", "27", "28", "29", _
"30", "31", "32", "33", "34", "35")
For intBrojac = 1 To Len(inTekst)
For intBrojac2 = 0 To UBound(Slova)
If Mid(inTekst, intBrojac, 1) = Slova(intBrojac2) Then
strTMP = strTMP & Vrednosti(intBrojac2)
End If
Next
Next
inTekst = strTMP
End Sub
A to bi trebalo da bude ovo (a ti ispravi sigurno ima poneka greska):
Code:
prvo idemo da obradimo string i da slova pretvorimo u cifre
function Obradi(s: string): string;
var
i: integer;
begin
s:=trim(uppercase(s));
result :='';
for i:=1 to length(s) do
if (s[i]>='0') and (s[i]<='9') then
result :=result +s[i]
else if (s[i]>='A') and (s[i]<='Z') then
result := result+inttostr(10+chr(s[i])-65);
end;
da kazemo da je to isto kao ona funkcija dole
idemo na racunanje:
function KB(k, br: string): string;
var
kontbr, inval, res:double;
begin
kontbr:=strtofloat(k);
inval := strtofloat(obradi(br))*100;
res:= roundto((inval/kontbr)-trunc(inval/kontbr),2);
res:=kontbr+1-round(res*kontbr);
result := rightstr(' '+floattostr(res),2);
end;
tako nekako...
naravno ovo ti nece raditi sa jako velikim brojevima.