473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Replacing Text Automatically - VB8

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.Keyboard.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 1144

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

Similar topics

5
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...
6
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...
6
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 {...
1
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...
12
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: ...
3
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...
3
by: baxy77bax | last post by:
hi, i have a question about replacing text after a defined string. for example : the text goes. ##|######|#######_##| ########... ##|######|#######_##|########... ...
4
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>") ...
3
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.