473,765 Members | 2,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Replacing Text Automatically - VB8

3 New Member
This was asked on CodeProject also but I haven't received a working reply so am posting here. The only reply I did get there suggested using "e.Handled = true" but that didn't work no matter where I put it.

Below is the section I'm having trouble with at the moment:

Expand|Select|Wrap|Line Numbers
  1.     Friend Sub glbHooks_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs) Handles glbHooks.KeyPress
  2.         newStr = newStr & LCase(e.KeyChar)
  3.         n = 0
  4.  
  5.         If e.KeyChar = vbBack Then
  6.             tmpStr = ""
  7.             For i = 1 To newStr.Length
  8.                 If i < newStr.Length - 1 Then tmpStr = tmpStr & newStr.Substring(i - 1, 1)
  9.             Next
  10.             newStr = tmpStr
  11.         End If
  12.  
  13.         If newStr.Length = 4 Then
  14.             If newStr(3) = "-" Then
  15.                 If InStr(rkSet, newStr) Then
  16.                     n = 1
  17.                     My.Computer.Keyboard.SendKeys(Chr(8) & Chr(8) & Chr(8) & dicRepStr(newStr))
  18.                     newStr = ""
  19.                 End If
  20.  
  21.             End If
  22.  
  23.             tmpStr = ""
  24.             For i = 1 To newStr.Length
  25.                 If i <> 1 Then tmpStr = tmpStr & newStr.Substring(i - 1, 1)
  26.             Next
  27.             newStr = tmpStr
  28.         End If
  29.  
  30.         If n = 1 Then
  31.             Sleep(100)
  32.             My.Computer.Keyboard.SendKeys(Chr(8) & " ")
  33.         End If
  34.     End Sub
  35.  
What this is supposed to do is replace a 4-char usercode with user's choice of text. It works great but it adds a dash {-} at the end of the replacement text. The user chooses which symbol is the trigger and in my tests I'm using the dash. Which means the program is including the last-typed character.

I added the last "If" statement to try and remove it then add a space but it does no good. It just puts the dash AFTER the space.

Also, if I put "If n = 1 Then My.Computer.Key board.SendKeys( Chr(8))" at the beginning of this Sub then it will remove the dash after typing the next character. BTW the "Chr(8)" I tried when the "vbBack" wasn't taking out the dash, that's the only reason it's there now. Also, I originally had 4 "vbBack" {Chr(8)} in the replacing portion but have changed it around to try to get rid of that final character.

How do I get it so it won't send the dash {or whatever is chosen as the trigger symbol}?

Also, if I put a msgbox in that section then it doesn't put in the trigger character.
--> MsgBox("")
So is there a way to spoof a message box or something similar? I don't want to have to click "Okay" on the message box every time I use the hotkeys. I've tried sleep {for 100 & 500} but it didn't work.

Any help in this would be appreciated!

Peace to you and yours,
Matthew "Dra'Gon" Stohler
Mar 25 '12 #1
0 1158

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2329
by: WindAndWaves | last post by:
Hi Gurus I have a PHP page that allows a user to preview an email and then send it if(s)he is happy with it. Otherwise, they can click on an edit button and edit the text of the message. The text is then shown in a textarea element. While in situation A (the preview), a bit of formatting is useful (e.g <BR>), all of this formatting is a nuisance in the textarea.
6
4134
by: Jerry Werner | last post by:
I need to replace my email address on hundreds of web pages with a new address (in a graphic, not a mailto) in order to thwart the email harvesters that spammers are using. Ideally, I'd like to do so while maintaining the same file dates. My web site is currently hosted on a Sun/Solaris/Apache platform. Does anyone know of a reliable way to recursively replace one text string with another, either using unix commands, a proven perl...
6
3627
by: Peter Foti | last post by:
I have seen lots of examples where some HTML text is replaced with a background image using CSS. For example, replacing the text of an <h1> with a graphical logo, like so: CSS: h1 span { display: none; } h1 { height: 100px; background: url("mycompany.gif") no-repeat 35px 40px; } HTML: <h1><span>My Company</span></h1>
1
2184
by: Andrew Poulos | last post by:
Say I have a page, which has been created by a third party, and the page may contain some pre-specified text. How can I find and replace that text dynamically? For example, if the page I have contains this HTML: <div id=”oDiv” style="margin-bottom:10px;">{when}</div> <div> <table style="border:1px solid gray"> <tr> <td>blah</td>
12
5926
by: Adam J. Schaff | last post by:
I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look like: <gibberish>file//g:\pathtofile1<gibberish>file//g:\pathtofile2<gibberish> etc. I want to remove the "g:\" from the file paths. I wrote a console app that successfully reads the file and writes a duplicate of it, but fails for some reason to do the "replacing" of the "g:\". The code...
3
1354
by: TobyD | last post by:
I am a beginner programmer in VB and need help. If I have a string with a return, how do I exchange the return with a return and tab? Currently I am entering a string with EnterKeyBehavior enabled so I get text and returns within the text string. However, I need to replace the return string with return plus tab. How do I do this? Thanks
3
1679
by: baxy77bax | last post by:
hi, i have a question about replacing text after a defined string. for example : the text goes. ##|######|#######_##| ########... ##|######|#######_##|########... ...
4
1860
by: wildman | last post by:
RE: Replacing Text without changing case?? This code works great, but case has to be exact. Research.Text = Research.Text.Replace(textboxSearch.Text, "<b>" + textboxSearch.Text + "</b>") I found some c# code, but I can't make it work in vb.net:
3
1212
by: Oltmans | last post by:
Hi, I'm new to Python (and admittedly not a very good programmer) and I've come across a scenario where I've to search and replace text in a file. For the sake of an example, I'm searching for every occurence of the text http://www.hotmail.com -Hotmail]]
1
7863
by: =?ISO-8859-1?Q?S=F8ren?= | last post by:
Hi guys I got the following code: ------------------------------------------------------- Dim Word As New Microsoft.Office.Interop.Word.Application Dim Document As Microsoft.Office.Interop.Word.Document Document = Word.Documents.Open(Filename)
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8833
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.