Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB6 SendKeys

Posted on 2011-03-19
4
Medium Priority
?
807 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Accepted Solution

by:
kbirecki earned 2000 total points
ID: 35173716
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
ID: 35173758
-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)
ID: 35174154
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
ID: 35174894
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

610 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