KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Using line break characters like vbNewLine in strings
Topic Summary:
Created On: 03/05/2022 01:36 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 Using line break characters like vbNewLine in strings   - wristofdoom - 03/05/2022 01:36 PM  
 Using line break characters like vbNewLine in strings   - Alan Cantor - 03/05/2022 03:00 PM  
 Using line break characters like vbNewLine in strings   - wristofdoom - 03/05/2022 04:02 PM  
 Using line break characters like vbNewLine in strings   - Alan Cantor - 03/05/2022 04:35 PM  
 Using line break characters like vbNewLine in strings   - noblemd - 03/05/2022 06:32 PM  
 Using line break characters like vbNewLine in strings   - wristofdoom - 03/05/2022 08:06 PM  
 Using line break characters like vbNewLine in strings   - kkkwj - 03/10/2022 06:34 PM  
Keyword
 03/05/2022 01:36 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Top-Tier Member

Posts: 322
Joined: 09/03/2020

Hi,

I want to output text that has line breaks. In this scenario, I cannot use SendKeys "{enter}"  to create the line spacing, so I am trying to use vbNewLine  

The below code works, but it makes use of the clipboard, which is not ideal.

Sub Main
    Dim output1 As String
   output1 = "testing" & vbNewLine & "testing"
   Clipboard output1
   SendKeys "^v"
End Sub

 

I wanted to do something like this:

 

Sub Main
    Dim output1 As String
   output1 = "testing" & vbNewLine & "testing"
   SendKeys output1
End Sub

But that gives me an error. Not sure why.

So is there a better way to instert this text in a way that does not make use of SendKeys "{enter}" to create the linebreaks, and does not make use of the clipboard?



-------------------------

Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017.

 03/05/2022 03:00 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4313
Joined: 12/08/2007

I'm not sure why, but you may need to use SendSystemKeys or SendDragonKeys, perhaps something like this:

Sub Main
Dim output1 As String
output1 = "testing" & Chr(10) & "testing"
SendDragonKeys output1
End Sub
 03/05/2022 04:02 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Top-Tier Member

Posts: 322
Joined: 09/03/2020

Thanks. Is Chr(10) better than vbNewline?

-------------------------

Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017.

 03/05/2022 04:35 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4313
Joined: 12/08/2007

No better. But it works!
 03/05/2022 06:32 PM
User is offline View Users Profile Print this message

Author Icon
noblemd
Junior Member

Posts: 37
Joined: 08/09/2019

In MsgBox, I use: MsgBox "First Line" + Chr$(13) + Chr$(10) + "Second Line"

The ASCII character code 13 is called a Carriage Return or CR. On windows based computers files are typically delimited with a Carriage Return Line Feed or CRLF. So a Chr (13) followed by a Chr (10) composes a proper CRLF.

Different text editors/viewers will interpret it differently. Sometimes a CRLF is needed.

See this about vbNewLine

https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualbasic.constants.vbnewline?view=net-6.0

 



-------------------------

Michael Noble
-------------------------
Using $20 USB Mic on adjustable arm ($30 total cost - 99.9% recognition). 


 


DPI 15.61.200.010 - Windows 11 Pro for Workstations Latest Update / MS Office 2021 LTSC



 03/05/2022 08:06 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Top-Tier Member

Posts: 322
Joined: 09/03/2020

Thanks.

 

So why the preference for the  "Char" format rather than vbCrLf like the documentation suggests?

 

Also, this is off topic, but regarding your signature, what's the secret to your $30 / 99 percent accuracy microphone situation?



-------------------------

Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017.

 03/10/2022 06:34 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 916
Joined: 11/05/2015

I would guess that using the Chr$(..) format works for all ASCII characters and so can easily become a habit - treat everything the same way. Having said that, I use vbCrLf when I want that particular combination. It's a matter of personal preference. You can also use the escape sequences in some languages like "\n\r" for newline + return.

-------------------------

Win10/11/x64, AMD Ryzen 7 3700X/3950X, 64/128GB RAM, Dragon 15.3, SP 7 Standard, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Amazon YUWAKAYI headset, Klim and JUKSTG earbuds with microphones, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse

Statistics
32305 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 0 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 531 guests browsing this forum, which makes a total of 531 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2022 FuseTalk™ Inc. All rights reserved.