Solved

VB6 SendKeys

Posted on 2011-03-19
4
783 Views
Last Modified: 2012-05-11
How do I get back to tab position #1 ie:

I want the 4th box to say "Hello":
    WebBrowser2.SetFocus
    SendKeys ("{Tab}")
    SendKeys ("{Tab}")
    SendKeys ("{Tab}")
    SendKeys ("Hello")

Then I want the 3rd box to say "World":
    WebBrowser2.SetFocus
    SendKeys ("{Tab}")
    SendKeys ("{Tab}")
    SendKeys ("World")
0
Comment
Question by:hrolsons
4 Comments
 
LVL 11

Accepted Solution

by:
kbirecki earned 500 total points
Comment Utility
Can you use Shift-Tab to backup one field at a time:

 SendKeys ("+{Tab}")

"+" is the shift key.  Repeat that as many times as you need.  Does that work for you?
0
 
LVL 23

Expert Comment

by:OP_Zaharin
Comment Utility
-to simplify your codes, you can use for-loop:

 WebBrowser2.SetFocus
 For i = 1 to 3
    SendKeys ("{TAB}"), True
 Next i
 SendKeys "Hello"
 SendKeys ("+{TAB}")

and you might want to look at this example using keyboard event: http://www.freevbcode.com/ShowCode.Asp?ID=340
0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
Comment Utility
have you tried using the elements of the webbrowser control rather than sendkeys.  SendKeys is quite unreliable as it relies upon an application not losing focus or repainting.

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_25082070.html

http://vbcity.com/blogs/jatkinson/archive/2009/12/12/programmatically-entering-and-data-using-the-webbrowser-control.aspx

if you can look at the webpage source and post the relevant parts, we can help determine the elements you wish to reference and set them diagrammatically rather than using sendkeys.
0
 
LVL 4

Expert Comment

by:coolcurrent4u
Comment Utility
if you want to write any of those words at a particular control, e.g textbox, you can call textbox1.setfocus() instead.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now