############谁能帮忙将下面VB函数翻译成DELPHI,解决后马上放分,谢谢(100分)

  • 主题发起人 主题发起人 joshua_jia
  • 开始时间 开始时间
J

joshua_jia

Unregistered / Unconfirmed
GUEST, unregistred user!
谁能帮忙将下面VB函数翻译成DELPHI,谢了

Function ShowMc(aa As String, b As String, c As String, d As String) As String
Dim slen As Integer
Dim adress As Integer '数据基地址
Dim sum As Integer '字段的个数
Dim tag As String '字段标识符
Dim middle As String '目次区内容
Dim data As String '数据区内容
Dim xx As Variant '数据字段数组
Dim zz As Variant '数据子字段数组
Dim x As Integer
Dim jsq As Integer '记数器
Dim temp As Variant '临时数组
Dim start As String
Dim finish As String

slen = Val(Mid(aa, 1, 5))
adress = Val(Mid(aa, 13, 5))
'sum = (adress - 24) / 12
middle = Mid(aa, 25, adress - 24 - 1)
data = Mid(aa, adress, slen - adress + 1)

x = 1
jsq = 1
tag = ""
temp = Split(data, Chr(30))
sum = UBound(temp)
While jsq <= sum
tag = Mid(middle, x, 3) ' 字段标识符
If tag = b Then
xx = Split(data, Chr(30)) '数据字段数组
start = InStr(1, xx(jsq), c) '子字段起始地址
finish = InStr(start + 1, xx(jsq), "$") '子字段结束地址
If finish < start Then
d = Mid(xx(jsq), start + 2, Len(xx(jsq)) - start - 1) '当该子字段为字段最后子字段时的内容
Else
d = Mid(xx(jsq), start + 2, finish - start - 2) '子字段内容
End If
End If
jsq = jsq + 1
x = x + 12
Wend
End Function
 
slen = Val(copy(aa, 1, 5), i, code)
adress = Val(Mid(aa, 13, 5), i, code)
sum = (adress - 24) / 12
middle = copy(aa, 25, adress - 24 - 1)
data = copy(aa, adress, slen - adress + 1)

x = 1
jsq = 1
tag = ""
temp = VarArrayCreate(data, 30);
sum = vararraylowbound(temp);
While jsq <= sum ;
tag = copy(middle, x, 3) ' 字段标识符;
If tag = b Then
xx = VarArrayCreate(data, Chr(30)) '数据字段数组
start = pos(xx(jsq), c) '子字段起始地址
finish = pos(xx(jsq), "$") '子字段结束地址
If finish < start Then
d = copy(xx(jsq), start + 2, Length(xx(jsq)) - start - 1) '当该子字段为字段最后子字段时的内容
Else
d = copy(xx(jsq), start + 2, finish - start - 2) '子字段内容
End If
End If
jsq = jsq + 1
x = x + 12
 
temp = VarArrayCreate(data, 30);
这里报错,类型不符,应该怎么改呀
 
data
把这个改为字符数组试试
 
郁闷,还没解决
 
temp = VarArrayCreate(DateToStr(data), 30);
 
没有测试,请谅解:
Function ShowMc(aa,b,c,d:String):String;
var slen,adress ,sum ,x,jsq:Integer;
tag,middle ,data ,start ,finish :String;
xx,zz,temp:TStringList;
begin
slen := strtoint(copy(aa, 1, 5));
adress := strtoint(copy(aa, 13, 5));
'sum := (adress - 24) div 12
middle := copy(aa, 25, adress - 24 - 1);
data := copy(aa, adress, slen - adress + 1);

x := 1;
jsq := 1;
tag := '';
temp :=tstringlist.create;
xx :=tstringlist.create;
zz :=tstringlist.create;
Split(data, Chr(30),temp );
sum = temp.count;
While jsq <= sum do begin
tag = copy(middle, x, 3);// ' 字段标识符
If tag = b Then begin
xx.Clear;
Split(data, Chr(30),xx) //'数据字段数组
start := pos(c, xx(jsq));// '子字段起始地址
finish := pos("$",copy(xx(jsq),start + 1,length(xx(jsq)) );// '子字段结束地址
If finish < start Then
d := copy(xx(jsq), start + 2, Len(xx(jsq)) - start - 1)// '当该子字段为字段最后子字段时的内容
Else
d := copy(xx(jsq), start + 2, finish - start - 2);// '子字段内容

end;
jsq := jsq + 1;
x := x + 12;
end;
End;

procedure Split(s,SpliteStr:string;L:TStringlist);
Var I:INTEGER;
begin
l.Clear;
i:=pos(SpliteStr,s);
while i>0 do begin
L.Add(copy(s,1,i-1));
delete(s,1,i);
i:=pos(SpliteStr,s);
end;
L.Add(s);
end;
 
我最恨这样的懒人,一点技术含量都没有
溜了
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
843
import
I
S
回复
0
查看
928
SUNSTONE的Delphi笔记
S
后退
顶部