Please can someone help me, I can't seem to get a bit of my code to work. Here is what I have:
The bit that dosen't seem to work is thebit
I am running ti with two entries so it should run twice for each policy (i.e. the PolNo will be 2 policiy numbers). But the above code counts each policy twice. The value of TOtalWop for the first policy is £20 and £30 for the second, but it counts them twice so the TotalWop is totalling £100.
please help!
Code:
For polroutine = 0 To 4
PolNo = polarray(polroutine)
If PolNo = "" Then GoTo polcont2
'enter policy no
backoutchk = MyScreen.getstring(2, 3, 7)
If backoutchk = "BRPEIMA" Then Sess0.Screen.SendKeys ("<Pf3>")
Sess0.Screen.WaitHostQuiet (g_hostsettletime)
If backoutchk = "BRPEBMD" Then Sess0.Screen.SendKeys ("<Pf3>")
Sess0.Screen.WaitHostQuiet (g_hostsettletime)
If backoutchk = "BRPEDMA" Then Sess0.Screen.SendKeys ("<Pf3>")
Sess0.Screen.WaitHostQuiet (g_hostsettletime)
Sess0.Screen.SendKeys ("<EraseEOF>")
MyScreen.Putstring PolNo, 21, 9
MyScreen.Moveto 21, 68
Sess0.Screen.SendKeys ("PEB")
Sess0.Screen.SendKeys ("<Enter>")
Sess0.Screen.WaitHostQuiet (g_hostsettletime)
ioforcechk = MyScreen.getstring(4, 22, 12)
If ioforcechk = "OUT OF FORCE" Then MsgBox ("OUT OF FORCE POLICY"): End 'used to be GoTo inputs1 '???????
GoTo Infoscrape
'Gets the information to input on the policy details
Infoscrape:
premium1 = MyScreen.getstring(15, 55, 10)
premium1 = Val(premium1)
premium = premium + premium1
Sess0.Screen.SendKeys ("<Enter>")
Sess0.Screen.WaitHostQuiet (g_hostsettletime)
specdate = MyScreen.getstring(8, 38, 10)
specdate = Format(specdate, "d mmmm yyyy")
CommDate = MyScreen.getstring(7, 38, 10)
Termdate = MyScreen.getstring(8, 38, 10)
'Search the screen for any life cover groups
Sess0.Screen.WaitHostQuiet (g_hostsettletime)
Nam3 = MyScreen.getstring(5, 25, 3)
nxtstep:
'searches for waiver of premium
wopchk = MyScreen.getstring(5, 55, 11)
If wopchk = "EYP ABSENT " Then
wopchk = False
Else
wopchk = True
End If
GoTo spchk
spchk:
PageVal = MyScreen.getstring(3, 80, 1)
PageVal = Val(PageVal)
PUPCheck = MyScreen.getstring(10, 9, 2)
If PUPCheck = "SP" Then SPStatus = True
For PolRoute = 1 To PageVal
FigRow = 9
FigRow2 = FigRow - 2
FigRow3 = FigRow - 2
For figroutine = 1 To 3
Sess0.Screen.WaitHostQuiet (g_hostsettletime)
firstchk:
'Check group is active - move onto next group if it isn't
figChk = MyScreen.getstring(FigRow - 1, 74, 1)
If figChk = " " Then
GoTo nextchk
Else
FigRow = FigRow + 5
FigRow2 = FigRow - 2
FigRow3 = FigRow - 2
GoTo firstchk
End If
nextchk:
'Check for single premiums
figComChk = MyScreen.getstring(FigRow - 2, 38, 10)
figTermChk = MyScreen.getstring(FigRow + 1, 38, 10)
If figComChk = figTermChk Then
FigRow = FigRow + 5
FigRow2 = FigRow - 2
FigRow3 = FigRow - 2
GoTo nextfig
End If
spchk = MyScreen.getstring(FigRow, 13, 2)
Widowsben = MyScreen.getstring(FigRow2, 19, 1)
LifeCover = MyScreen.getstring(FigRow3, 19, 1)
If Widowsben = "2" Then
widowsbenTermDate = MyScreen.getstring(FigRow2, 38, 10)
widowsPrem = MyScreen.getstring(9, 17, 10)
widowsPrem = Val(widowsPrem)
FigRow = FigRow + 5
FigRow2 = FigRow2 + 5
FigRow3 = FigRow3 + 5
GoTo nextfig
End If
If LifeCover = "3" Then
LC_Present = True
lcstopcode = MyScreen.getstring(FigRow - 1, 74, 1)
LifeCoverTermDate = MyScreen.getstring(FigRow3 + 1, 38, 10)
SumAssured1 = MyScreen.getstring(FigRow3 + 1, 17, 10)
SumAssured1 = Val(SumAssured1)
SumAssured = SummAssured + SumAssured1
LCpremium1 = MyScreen.getstring(FigRow, 38, 10)
LCpremium1 = Val(LCpremium1)
LCPremium = LCPremium + LCpremium1
LCCessationDate = MyScreen.getstring(FigRow3 + 3, 38, 10)
FigRow = FigRow + 5
FigRow2 = FigRow2 + 5
FigRow3 = FigRow3 + 5
GoTo nextfig
End If
If spchk = "SP" Then SPfig = MyScreen.getstring(FigRow, 17, 10): _
SPfig = Val(SPfig): _
SPamount = SPamount + SPfig
'Get BA
BAfig = MyScreen.getstring(FigRow3 + 1, 17, 10)
BAfig = Val(BAfig)
'Get Bonus
Bonfig = MyScreen.getstring(FigRow3 + 1, 57, 10)
Bonfig = Val(Bonfig)
'Compile values
FigRow = FigRow + 5
FigRow2 = FigRow2 + 5
FigRow3 = FigRow3 + 5
BA = BA + BAfig
Bonus = Bonus + Bonfig
nextfig:
Next
Sess0.Screen.SendKeys ("<Pf8>")
Sess0.Screen.WaitHostQuiet (g_hostsettletime)
Next
'Check for WOP and get values
Sess0.Screen.SendKeys ("<Enter>")
Sess0.Screen.WaitHostQuiet (g_hostsettletime)
For woproutine = 1 To 9
PWChk = MyScreen.getstring(7 + woproutine, 7, 2)
If PWChk = "PW" Then wopprem = MyScreen.getstring(7 + woproutine, 12, 8)
wopprem = CCur(wopprem)
wopprem = Val(wopprem)
TotalWop = TotalWop + wopprem
wopprem = 0
Next
polcont2:
Next
ben1prem = premium - TotalWop - LCPremium - widowsPrem
ben1prem = Format(ben1prem, "£##,##0.00")
'POPULATE EXCEL WITH DATA
Sheets("Data").Activate
Cells(24, 2) = NPDD
Cells(25, 2) = premium
Cells(26, 2) = WOPtermdate
Cells(27, 2) = BA
Cells(28, 2) = ben1prem
Cells(29, 2) = Ben2Prem
Cells(30, 2) = Ben3prem
End
The bit that dosen't seem to work is thebit
Code:
For woproutine = 1 To 9
PWChk = MyScreen.getstring(7 + woproutine, 7, 2)
If PWChk = "PW" Then wopprem = MyScreen.getstring(7 + woproutine, 12, 8)
wopprem = CCur(wopprem)
wopprem = Val(wopprem)
TotalWop = TotalWop + wopprem
wopprem = 0
Next
I am running ti with two entries so it should run twice for each policy (i.e. the PolNo will be 2 policiy numbers). But the above code counts each policy twice. The value of TOtalWop for the first policy is £20 and £30 for the second, but it counts them twice so the TotalWop is totalling £100.
please help!