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
Solved

VB6 SendKeys

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA open file from excel cell 4 44
MS Access Search and Replace Using VBA 6 83
how to Classify of email (pdf attachments) 7 45
backup program with robocopy 6 45
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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

828 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