Solved

VB6 SendKeys

Posted on 2011-03-19
4
802 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

690 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