|
-
Feb 21st, 2000, 02:09 AM
#1
Thread Starter
New Member
In a program Im making you put a text in a textbox and that text gets the decleration utfylling. Then a button triggers the sendkeys function and it sends everything to another program. The fault is that if we imagine a text like for example:
"erafajklaf
fajkdf´j"
..it becomes
"erafajklaf
fjakdfla"
and since I cant edit the text due to the way the other program is made the text comes out wrong.
What can I do to escape the "enter" that always goes between the lines
I would love some help
-
Feb 21st, 2000, 02:31 AM
#2
Don't forget to send vbCrLf along with your other strings. So example would be like this:
SendKeys "Text1"
SendKeys vbCrlf
SendKeys "Text2"
------------------
Serge
Senior Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819
-
Feb 21st, 2000, 01:55 PM
#3
Frenzied Member
I am reading your problem differently than Serge was. If he helped you, then ignore this. But if you are asking how to GET RID OF the return character in a string before sending it to another app, here's how.
To use this example, create a form with 2 Text Boxes (Text1 and Text2). Make them fairly wide (5" or so), tall enough to hold 5-6 lines of text, and make sure that you set the Multiline property to TRUE for each of them (so you can use the Enter key within the box). Also create a command button (Command1) on the form.
Type the following code into the form's code window:
Code:
Option Explicit
' Make sure that the multi-line property of Text1 and Text2 is set to TRUE
' so that you can use the enter key within the box.
Private Sub Command1_Click()
Dim sTemp As String
Dim nCounter As Integer
' This loop inserts each character from the text of Text1 into the
' variable sTemp until a CarriageReturn/LineFeed is encountered. This
' is then replaced with a space character, resulting in a conversion
' from a multi-line text to a single-line text.
For nCounter = 1 To Len(Text1)
If Mid$(Text1, nCounter, 1) <> Chr(13) And _
Mid$(Text1, nCounter, 1) <> Chr(10) Then
sTemp = sTemp & Mid$(Text1, nCounter, 1)
' Include this else statement if you want to replace
' the return character with a space instead.
ElseIf Mid$(Text1, nCounter, 1) = Chr(13) Then
sTemp = sTemp & " "
End If
Next nCounter
'The new single line text is displayed in Text2
Text2 = sTemp
End Sub
To use this example, type text into Text1 using the enter key, so that you have seperate words on different lines. Then press the Command button. The code removes the "Enter" keys and replaces them with spaces, then displays the result in Text2.
Hope this helped a little.
~seaweed
[This message has been edited by seaweed (edited 02-22-2000).]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|