跪求vb,delphi 高手把下面代码改成delphi的
TypeEvalTypeNameAsString'nameofevaluationfactor(e.g.NE-Diet)UnitsAsString'unitsofeval...
Type EvalType
Name As String ' name of evaluation factor (e.g. NE-Diet)
Units As String ' units of evaluation factor (e.g. Mcal/day)
Total As Single
Maint As Single
Preg As Single
Lact As Single
Gain As Single
Reserves As Single
End Type
Public EvalFactor(1 To 6) As EvalType
Private Sub DietEvalOneComputations()
Dim X As Integer
' The EvalFactors are calculated here as follows :
'
' NE Diet, NE Required, NE Differ, MP Diet, MP Required, MP Differ
' Mcal/d Mcal/d Mcal/d g/d g/d g/d
If AnimalType <> "Replacement Heifer" Then
EvalFactor(1).Name = "NE Supplied"
EvalFactor(2).Name = "NE Required"
EvalFactor(3).Name = "NE (Diet - Req.)"
EvalFactor(4).Name = "MP Diet"
EvalFactor(5).Name = "MP Required"
EvalFactor(6).Name = "MP (Diet - Req.)"
Else
EvalFactor(1).Name = "ME Supplied"
EvalFactor(2).Name = "ME Required"
EvalFactor(3).Name = "ME (Diet - Req.)"
EvalFactor(4).Name = "MP Diet"
EvalFactor(5).Name = "MP Required"
EvalFactor(6).Name = "MP (Diet - Req.)"
End If
For X = 1 To 6
If X < 4 Then
EvalFactor(X).Units = "Mcal/day"
Else
EvalFactor(X).Units = "g/day"
End If
Next X
If AnimalType <> "Replacement Heifer" Then
EvalFactor(1).Total = NEl_Total
Else
EvalFactor(1).Total = MEng_Total
End If
EvalFactor(1).Maint = EvalFactor(1).Total
If AnimalType <> "Replacement Heifer" Then
EvalFactor(2).Maint = NEMaint
Else
If NEmOverMEng > 0 Then
EvalFactor(2).Maint = NEMaint / NEmOverMEng
Else
EvalFactor(2).Maint = 0
End If
End If 展开
Name As String ' name of evaluation factor (e.g. NE-Diet)
Units As String ' units of evaluation factor (e.g. Mcal/day)
Total As Single
Maint As Single
Preg As Single
Lact As Single
Gain As Single
Reserves As Single
End Type
Public EvalFactor(1 To 6) As EvalType
Private Sub DietEvalOneComputations()
Dim X As Integer
' The EvalFactors are calculated here as follows :
'
' NE Diet, NE Required, NE Differ, MP Diet, MP Required, MP Differ
' Mcal/d Mcal/d Mcal/d g/d g/d g/d
If AnimalType <> "Replacement Heifer" Then
EvalFactor(1).Name = "NE Supplied"
EvalFactor(2).Name = "NE Required"
EvalFactor(3).Name = "NE (Diet - Req.)"
EvalFactor(4).Name = "MP Diet"
EvalFactor(5).Name = "MP Required"
EvalFactor(6).Name = "MP (Diet - Req.)"
Else
EvalFactor(1).Name = "ME Supplied"
EvalFactor(2).Name = "ME Required"
EvalFactor(3).Name = "ME (Diet - Req.)"
EvalFactor(4).Name = "MP Diet"
EvalFactor(5).Name = "MP Required"
EvalFactor(6).Name = "MP (Diet - Req.)"
End If
For X = 1 To 6
If X < 4 Then
EvalFactor(X).Units = "Mcal/day"
Else
EvalFactor(X).Units = "g/day"
End If
Next X
If AnimalType <> "Replacement Heifer" Then
EvalFactor(1).Total = NEl_Total
Else
EvalFactor(1).Total = MEng_Total
End If
EvalFactor(1).Maint = EvalFactor(1).Total
If AnimalType <> "Replacement Heifer" Then
EvalFactor(2).Maint = NEMaint
Else
If NEmOverMEng > 0 Then
EvalFactor(2).Maint = NEMaint / NEmOverMEng
Else
EvalFactor(2).Maint = 0
End If
End If 展开
3个回答
展开全部
//由于提供的代码不全,只能根据给出的代码进行改写,具体如下:
type
EvalType = packed record //原本想新建一个类 但考虑到类需要实例化 还是用结构比较简单
Name: String;
Units: String;
Total: Single;
Maint: Single;
Preg: Single;
Lact: Single;
Gain: Single;
Reserves: Single;
end;
var
EvalFactor: array[1..6] of EvalType;
procedure DietEvalOneComputations;
var
x: integer;
begin
if AnimalType <> 'Replacement Heifer' then
begin
EvalFactor[1].Name := 'NE Supplied';
EvalFactor[2].Name := 'NE Required';
EvalFactor[3].Name := 'NE (Diet - Req.)';
EvalFactor[4].Name := 'MP Diet';
EvalFactor[5].Name := 'MP Required';
EvalFactor[6].Name := 'MP (Diet - Req.)';
end
else
begin
EvalFactor[1].Name := 'ME Supplied';
EvalFactor[2].Name := 'ME Required';
EvalFactor[3].Name := 'ME (Diet - Req.)';
EvalFactor[4].Name := 'MP Diet';
EvalFactor[5].Name := 'MP Required';
EvalFactor[6].Name := 'MP (Diet - Req.)';
end;
for x:= 1 to 6 do
begin
if x < 4 then
EvalFactor[x].Units := 'Mcal/day'
else
EvalFactor[x].Units := 'g/day';
end;
if AnimalType <> 'Replacement Heifer' then
EvalFactor[1].Total := NEI_Total
else
EvalFactor[1].Total := MEng_Total;
EvalFactor[1].Maint := EvalFactor[1].Total;
if AnimalType <> 'Replacement Heifer' then
EvalFactor[2].Maint := NEMaint
else
begin
if NEmOverMEng > 0 then
EvalFactor[2].Maint := NEMaint / NEmOverMEng
else
EvalFactor[2].Maint := 0;
end;
end;
//如楼上所说,建议楼主以后求代码多少给点分数,不然真不太有人愿意写
type
EvalType = packed record //原本想新建一个类 但考虑到类需要实例化 还是用结构比较简单
Name: String;
Units: String;
Total: Single;
Maint: Single;
Preg: Single;
Lact: Single;
Gain: Single;
Reserves: Single;
end;
var
EvalFactor: array[1..6] of EvalType;
procedure DietEvalOneComputations;
var
x: integer;
begin
if AnimalType <> 'Replacement Heifer' then
begin
EvalFactor[1].Name := 'NE Supplied';
EvalFactor[2].Name := 'NE Required';
EvalFactor[3].Name := 'NE (Diet - Req.)';
EvalFactor[4].Name := 'MP Diet';
EvalFactor[5].Name := 'MP Required';
EvalFactor[6].Name := 'MP (Diet - Req.)';
end
else
begin
EvalFactor[1].Name := 'ME Supplied';
EvalFactor[2].Name := 'ME Required';
EvalFactor[3].Name := 'ME (Diet - Req.)';
EvalFactor[4].Name := 'MP Diet';
EvalFactor[5].Name := 'MP Required';
EvalFactor[6].Name := 'MP (Diet - Req.)';
end;
for x:= 1 to 6 do
begin
if x < 4 then
EvalFactor[x].Units := 'Mcal/day'
else
EvalFactor[x].Units := 'g/day';
end;
if AnimalType <> 'Replacement Heifer' then
EvalFactor[1].Total := NEI_Total
else
EvalFactor[1].Total := MEng_Total;
EvalFactor[1].Maint := EvalFactor[1].Total;
if AnimalType <> 'Replacement Heifer' then
EvalFactor[2].Maint := NEMaint
else
begin
if NEmOverMEng > 0 then
EvalFactor[2].Maint := NEMaint / NEmOverMEng
else
EvalFactor[2].Maint := 0;
end;
end;
//如楼上所说,建议楼主以后求代码多少给点分数,不然真不太有人愿意写
追问
有分,昨天提问不了。我会追加分的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询