View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rick S. Rick S. is offline
external usenet poster
 
Posts: 213
Default Macro needed Fortran to VBA

Forgot to "End If"
"
Sub aaa()
'Declare variables
'Unless otherwise specified all variables below are Variants
Dim ER_ELIG As Boolean
Dim ERPOINTS 'if integer only then "Dim ERPOINTS as Integer"
Dim iage
Dim vsvcb
Dim IGRP
Dim ERF

ER_ELIG = False
ERPOINTS = iage + vsvcb
If IGRP = "1" And _
iage "55" And _
vsvcb "10" Then
ER_ELIG = True
End If

If IGRP = "2" And _
iage = "50" Then
ER_ELIG = True
End If
ERF = 0#
If ER_ELIG Then
If IGRP = "1" Then
If ERPOINTS = "75" Then
ERF = DIM ( 1. , .04*MIN(4,DIM(62,MAX(55,iage)))
+ .03*MIN(3,DIM(58,MAX(55,iage))) )
Else
ERF = DIM ( 1. , .0667*MIN(5,DIM(65,MAX(55,iage)))
+ .0333*MIN(5,DIM(60,MAX(55,iage))) )
End If
End If
End If

If vsvcb = "25" Then ERF = "1.000"
If iage = "62" And _
ERPOINTS = "75" Then
ERF = "1.000"
Else
ERF = DIM ( 1. , .018*MIN(2,DIM(62,MAX(50,iage)))
+ .036*MIN(5,DIM(60,MAX(50,iage)))
+ .052*MIN(5,DIM(55,MAX(50,iage))) )
If iage = "62" Then ERF = "1.000"
End If

End Sub
"

Since I can not test this, ending IF statements may not be 100% correct.
--
Regards

Rick


"Rick S." wrote:

What does "DIM" signify in Fortran?
" ERF = DIM ( 1. , .04*MIN(4,DIM(62,MAX(55,iage)))
+ .03*MIN(3,DIM(58,MAX(55,iage))) )

"


Here is a partial rewrite that may help you get going.
"
Sub aaa()
'Declare variables
'Unless otherwise specified all variables below are Variants
Dim ER_ELIG As Boolean
Dim ERPOINTS 'if integer only then "Dim ERPOINTS as Integer"
Dim iage
Dim vsvcb
Dim IGRP
Dim ERF

ER_ELIG = False
ERPOINTS = iage + vsvcb
If IGRP = "1" And _
iage "55" And _
vsvcb "10" Then
ER_ELIG = True

If IGRP = "2" And _
iage = "50" Then
ER_ELIG = True

ERF = 0#
If ER_ELIG Then
If IGRP = "1" Then
If ERPOINTS = "75" Then
ERF = DIM ( 1. , .04*MIN(4,DIM(62,MAX(55,iage)))
+ .03*MIN(3,DIM(58,MAX(55,iage))) )
Else
ERF = DIM ( 1. , .0667*MIN(5,DIM(65,MAX(55,iage)))
+ .0333*MIN(5,DIM(60,MAX(55,iage))) )
End If
If vsvcb = "25" Then ERF = "1.000"
If iage = "62" And _
ERPOINTS = "75" Then ERF = "1.000"
Else
ERF = DIM ( 1. , .018*MIN(2,DIM(62,MAX(50,iage)))
+ .036*MIN(5,DIM(60,MAX(50,iage)))
+ .052*MIN(5,DIM(55,MAX(50,iage))) )
If iage = "62" Then ERF = "1.000"
End If
End If

End Sub
"

Code that is still in Fiortran format I dont fully understand yet, they
appear to be formulas for calculations?

--
Regards

Rick


"sylphide" wrote:

Hi
I nned to convert a Fortran code in VBA:
ER_ELIG = .false.
ERPOINTS = iage + vsvcb
IF ((IGRP.eq.1).and.(iage.ge.55).and.(vsvcb.ge.10))
ER_ELIG = .true.


IF ((IGRP.eq.2).and.(iage.ge.50))
ER_ELIG = .true.


ERF = 0.00
IF (ER_ELIG) THEN
IF (IGRP.eq.1) THEN
IF (ERPOINTS.ge.75) then
ERF = DIM ( 1. , .04*MIN(4,DIM(62,MAX(55,iage)))
+ .03*MIN(3,DIM(58,MAX(55,iage))) )

ELSE
ERF = DIM ( 1. , .0667*MIN(5,DIM(65,MAX(55,iage)))
+ .0333*MIN(5,DIM(60,MAX(55,iage))) )

ENDIF
IF (vsvcb.ge.25) ERF = 1.000
IF ((iage.ge.62).and.(ERPOINTS.ge.75)) ERF = 1.000
ELSE
ERF = DIM ( 1. , .018*MIN(2,DIM(62,MAX(50,iage)))
+ .036*MIN(5,DIM(60,MAX(50,iage)))
+ .052*MIN(5,DIM(55,MAX(50,iage))) )

IF (iage.ge.62) ERF = 1.000
ENDIF
ENDIF

Anyone could help please?
Thanks in advance