Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i skip to next message box

Status
Not open for further replies.

link99sbc

Technical User
Apr 8, 2009
141
US
I have this part of my code setup to respond to user input.
there are 4 periods possible but if the user has less than 4 how do i skip to the next msgbox.

MsgBox"ENTER THE PERIODS"
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
Sess0.Screen.WaitForCursor 8,17
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Enter>")
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
obj.WorkSheets("sheet2").Cells(17, "C").Value = sess0.Screen.GetString(04, 39, 4) '1ST QTR
obj.WorkSheets("sheet2").Cells(29, "C").Value = sess0.Screen.GetString(09, 21, 10) '1ST QTR
Sess0.Screen.MoveTo 4,39
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
Sess0.Screen.WaitForCursor 8,17
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Enter>")
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
obj.WorkSheets("sheet2").Cells(18, "C").Value = sess0.Screen.GetString(04, 39, 4) '2ND QTR
obj.WorkSheets("sheet2").Cells(29, "D").Value = sess0.Screen.GetString(09, 21, 10) '2ND QTR
Sess0.Screen.MoveTo 4,39
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
Sess0.Screen.WaitForCursor 8,17
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Enter>")
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
obj.WorkSheets("sheet2").Cells(19, "C").Value = sess0.Screen.GetString(04, 39, 4) '3RD QTR
obj.WorkSheets("sheet2").Cells(29, "E").Value = sess0.Screen.GetString(09, 21, 10) '3RD QTR
Sess0.Screen.MoveTo 4,39
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
Sess0.Screen.WaitForCursor 8,17
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Enter>")
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
obj.WorkSheets("sheet2").Cells(20, "C").Value = sess0.Screen.GetString(04, 39, 4) '4TH QTR
obj.WorkSheets("sheet2").Cells(29, "F").Value = sess0.Screen.GetString(09, 21, 10) '4TH QTR
Sess0.Screen.MoveTo 4,39
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

'------skip to this msgbox if less than 4 periods selected above
MsgBox"(AVERAGE) ENTER THE PERIODS FOR (PAST PERIODS)"
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
Sess0.Screen.WaitForCursor 8,17
 


Hi,

First ask for the number of periods.

Then use that value as a loop limit, asking for the period values within the loop.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 


Leaving out the Extra! code for clarity and brevity, something like this...
Code:
    Dim ans, i As Integer, iEnd As Integer, lRow As Long, iCol As Integer
    
    ans = InputBox("ENTER Number of PERIODS")
    
    If ans > 0 Then
        iEnd = ans
        
        lRow = 17
        iCol = 3
        
        For i = 1 To iEnd
            ans = InputBox("ENTER PERIOD " & i & " value")
            If ans = "" Then
                Exit For
            Else
                obj.Worksheets("sheet2").Cells(lRow, "C").Value = _
                    Sess0.Screen.GetString(4, 39, 4)
                obj.Worksheets("sheet2").Cells(29, iCol).Value = _
                    Sess0.Screen.GetString(9, 21, 10) 
                    
                lRow = lRow + 1
                iCol = iCol + 1
                    
            End If
        Next
    End If

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
This is very nice except when the user enters the period i.e. 0707, the code doesn't enter it on the screen at 4,39 and enter to bring up that screen. each period entered should bring up the screen for that period.
 



Did you not read, "Leaving out the Extra! code for clarity and brevity..."

Can YOU not add the necessary Extra code?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
yes but i'm not sure where exactly to add it. I tried several different places but nothing worked.
 



PLEASE, PLEASE, PLEASE do not force me ask you for more complete information that is relevant and necessary to answer your question, like...

what code did you try that did not work???!!!

PLEASE THINK about what you post and provide CLEAR, CONCISE and COMPLETE information! Be prepared to work for your solution.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
your code is a little advanced for me. I understand some it but not all of it. I've tried to reason through it and I assume I need the value of "ans" so I tried this in a couple of places but didn't work. It compiles but Im not getting right.

Dim ans, i As Integer, iEnd As Integer, lRow As Long, iCol As Integer

ans = InputBox("ENTER Number of PERIODS")

If ans > 0 Then
iEnd = ans

lRow = 18
iCol = 3

For i = 1 To iEnd
ans = InputBox("ENTER PERIOD " & i & " value")
Sess0.Screen.Putstring.ans.value 4, 29
Sess0.Screen.SendKeys("<Enter>")
If ans = "" Then
Exit For
Else

obj.Worksheets("sheet2").Cells(lRow, "C").Value = _
Sess0.Screen.GetString(4, 39, 4)
obj.Worksheets("sheet2").Cells(29, iCol).Value = _
Sess0.Screen.GetString(9, 21, 10)


lRow = lRow + 1
iCol = iCol + 1

End If

Next
End If
 


Did you try checking Extra HELP on InputBox?
Code:
            ans = InputBox("ENTER PERIOD " & i & " value")
            Sess0.Screen.Putstring.ans.value 4, 29
First InputBox returns a STRING, not an object. Hence ans is a string variant, and has no properties like Value.

Second have you looked at Extra HELP on PutString? You have a DOT after PutString that does not belong there.
Code:
            ans = InputBox("ENTER PERIOD " & i & " value")
            Sess0.Screen.Putstring ans, 4, 29

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
I knew it had to be something stupid.
but at least I was close. I was awake until
2:00 am trying to figure this out.
Thanks Skip
 


Go get some sleep! ;-)

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top