|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
What am I doing wrong'Zephyr Passport PC to HOST' to search a page for a specific number, in this case it's "prod" and if it's not there then flip to the next screen until I reach a certain screen. after it serches the first page it just hits enter until it reaches the specific screen where it should stop Here's what I have so far '**************************************************************************************************************** For x = 7 To 37 If GetString(x, 57, 3) = prod Then prod1 = GetString(x, 6, 30) prod2 = GetString(x+1, 9, 25) stat = GetString(x, 64, 2) Else 'x = 7 To 37 If GetString(43, 73, 7) = "AMF7401" and GetString(x, 57, 3) <> prod Then SendHostKeys("<ENTER>") While(WaitForNoX (1) <> 0):Wend Else End If End If Next '**************************************************************************************************************** anyone have any ideas as to why it's not searching each page? scottmmc***@gmail.com wrote:
Show quoteHide quote > Hi, I'm pretty new to Visual basic and I'm trying to write a macro for just to get an idea of what you're doing, I re-wrote your code so that it's> 'Zephyr Passport PC to HOST' to search a page for a specific number, > in this case it's "prod" and if it's not there then flip to the next > screen until I reach a certain screen. > > after it serches the first page it just hits enter until it reaches > the specific screen where it should stop > > Here's what I have so far > '**************************************************************************************************************** > For x = 7 To 37 > If GetString(x, 57, 3) = prod Then > prod1 = GetString(x, 6, 30) > prod2 = GetString(x+1, 9, 25) > stat = GetString(x, 64, 2) > Else > 'x = 7 To 37 > If GetString(43, 73, 7) = "AMF7401" and GetString(x, 57, 3) <> prod > Then > SendHostKeys("<ENTER>") > While(WaitForNoX (1) <> 0):Wend > > Else > End If > End If > > Next > '**************************************************************************************************************** > > > anyone have any ideas as to why it's not searching each page? more 'self-descriptive' for row = 7 to 37 if getstring(row, 57, 3) = prod then 'prod is a 3 character string? prod1 = getstring(row, 6, 30) 'ok 30 char string from col 6, same row prod2 = getstring(row+1, 9, 25) ' 25 char string from col 9, next row stat = getstring(row, 64, 2) ' number (?) from col 64, same row else if getstring(43,73,7) = "AMF7401" and Getstring(row, 57, 3) <> prod then SendHostKeys("<Enter>") While(WaitForNoX (1) <> 0):Wend Else ' not needed, unless you're chopping out some code Endif Endif Next So, the way I read the above, if prod is there, get some data else look for "AMF7401" and the getstring doesn't have 'prod'. (useless - you've already established this with the opening IF) if both conditions are met, send an <enter> to the host. The host uses the <enter> to move to the next page in whatever spreadsheet or database the host is using. The WaitForNoX is for what - a host response that it's on the next page? This repeats from first page to the 21st page (FOR 7 to 37) I take it "AMF7401" is in the same cell on all 21 pages, and you're searching for 'prod' from line 7 on your first page to line 37 on the 37th page. (not 21 lines on each page?) Is this your logic, and is it attuned to what you're trying to achieve? Maybe Galen's right with your "While" and "Else" being swapped - I Dunno BTW, I'm looking at this from a VB6 perspective, not VBA or a .net variant Argusy On Feb 11, 6:08 am, argusy <arg***@slmember.on.net> wrote:
Show quoteHide quote > scottmmc***@gmail.com wrote: prod = a number pulled from another screen> > Hi, I'm pretty new to Visual basic and I'm trying to write a macro for > > 'Zephyr Passport PC to HOST' to search a page for a specific number, > > in this case it's "prod" and if it's not there then flip to the next > > screen until I reach a certain screen. > > > after it serches the first page it just hits enter until it reaches > > the specific screen where it should stop > > > Here's what I have so far > > '**************************************************************************************************************** > > For x = 7 To 37 > > If GetString(x, 57, 3) = prod Then > > prod1 = GetString(x, 6, 30) > > prod2 = GetString(x+1, 9, 25) > > stat = GetString(x, 64, 2) > > Else > > 'x = 7 To 37 > > If GetString(43, 73, 7) = "AMF7401" and GetString(x, 57, 3) <> prod > > Then > > SendHostKeys("<ENTER>") > > While(WaitForNoX (1) <> 0):Wend > > > Else > > End If > > End If > > > Next > > '**************************************************************************************************************** > > > anyone have any ideas as to why it's not searching each page? > > just to get an idea of what you're doing, I re-wrote your code so that it's > more 'self-descriptive' > > for row = 7 to 37 > if getstring(row, 57, 3) = prod then 'prod is a 3 character string? > prod1 = getstring(row, 6, 30) 'ok 30 char string from col 6, same row > prod2 = getstring(row+1, 9, 25) ' 25 char string from col 9, next row > stat = getstring(row, 64, 2) ' number (?) from col 64, same row > else > if getstring(43,73,7) = "AMF7401" and Getstring(row, 57, 3) <> prod then > SendHostKeys("<Enter>") > While(WaitForNoX (1) <> 0):Wend > Else ' not needed, unless you're chopping out some code > Endif > Endif > Next > > So, the way I read the above, if prod is there, get some data > else look for "AMF7401" and the getstring doesn't have 'prod'. > (useless - you've already established this with the opening IF) > if both conditions are met, send an <enter> to the host. > The host uses the <enter> to move to the next page in whatever > spreadsheet or database the host is using. > The WaitForNoX is for what - a host response that it's on the next page? > > This repeats from first page to the 21st page (FOR 7 to 37) > > I take it "AMF7401" is in the same cell on all 21 pages, > and you're searching for 'prod' from line 7 on your first page to > line 37 on the 37th page. (not 21 lines on each page?) > > Is this your logic, and is it attuned to what you're trying to achieve? > > Maybe Galen's right with your "While" and "Else" being swapped - I Dunno > > BTW, I'm looking at this from a VB6 perspective, not VBA or a .net variant > > Argusy- Hide quoted text - > > - Show quoted text - WaitForNoX just means "wait until the host finishes loading the screen" The best way I can describe this is.... I want it to search the "AMF7401" screen from row 7 to 37 for 'prod', if it doesn't find prod then hit enter(and repeat this progress until it reaches a screen that is not labeled "AMF7401") to add to my previous post.
I want it to search the "AMF7401" screen from row 7 to 37 for 'prod', if it doesn't find prod then hit enter and repeat this progress until it finds a number equal to 'prod' OR reaches a screen that is not labeled "AMF7401" scottmmc***@gmail.com wrote:
> to add to my previous post. so I think your logic should be> > I want it to search the "AMF7401" screen from row 7 to 37 for 'prod', > if it doesn't find prod then hit enter and repeat this progress until > it finds a number equal to 'prod' OR reaches a screen that is not > labeled "AMF7401" find a screen with a label with "AMF4701" 'the above could be part of the While.. Wend. Think about how to do it while label = "AMF4701" ' or however you're doing this bit for row = 7 to 37 ' search 21 lines on this 'page' if getstring() = prod then get the data next row if prod2 = "" then ' no data found, go to next page (could use 'stat') Send <enter> to host, wait for host to load page endif Wend ' no more pages with "AMF4701" There's a supposition about the above. 'prod' will be only on one line, on only one of the pages IF there's multiple returns, then you're only going to get the last one found, or you're going to have to put the returns into an array, or some other method of storing the multiple returns Btw, What are you working in. VB, VBA, .net? Graham On Feb 12, 7:48 am, argusy <arg***@slmember.on.net> wrote:
Show quoteHide quote > scottmmc***@gmail.com wrote: I've solved my little problem,> > to add to my previous post. > > > I want it to search the "AMF7401" screen from row 7 to 37 for 'prod', > > if it doesn't find prod then hit enter and repeat this progress until > > it finds a number equal to 'prod' OR reaches a screen that is not > > labeled "AMF7401" > > so I think your logic should be > > find a screen with a label with "AMF4701" > 'the above could be part of the While.. Wend. Think about how to do it > > while label = "AMF4701" ' or however you'redoingthis bit > > for row = 7 to 37 ' search 21 lines on this 'page' > if getstring() = prod then get the data > next row > if prod2 = "" then ' no data found, go to next page (could use 'stat') > Send <enter> to host, > wait for host to load page > endif > Wend ' no more pages with "AMF4701" > > There's a supposition about the above. > 'prod' will be only on one line, on only one of the pages > IF there's multiple returns, then you're only going to get the last one found, > or you're going to have to put the returns into an array, or some other method > of storing the multiple returns > > Btw, What are you working in. VB, VBA, .net? > > Graham I ended up using a loop function as shown below '----------------------------------------------------------------------------- Do Until prod1 <> "" For x = 7 To 37 If GetString(x,57,3) = prod and GetString(43, 73, 7) = "AMF7401" Then prod1 = GetString(x, 6, 30) stat = GetString(x, 64, 2) prod2 = GetString(x+1, 9, 25) End If Next If GetString(43, 73, 7) = "AMF7401" Then SendHostKeys("<ENTER>") WaitForNoX 10 WaitForHostUpdate(1) End If Loop '----------------------------------------------------------------------------- Hope this may help someone in the future! Thanks everyone for your help and suggestions!
VB6 runtime is supported on Windows 7
ListBox color Printing PictureBox Contents Stupid Format$ Question FYI: MS UK VB6 Usage survey/poll - update Reading Stack from VB6 How to read XML data stream via a URL address into a string ? Add objects already on form to Groupbox Directory Local or Network Shared MS Fax |
|||||||||||||||||||||||