473,395 Members | 1,368 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,395 software developers and data experts.

Help: the existence of vbCr.

2
Please help me to solve this problem:

Supposing I've received a string as "ABCD" & vbCr via Comm. port.
But the vbCr is no appearing in the Text box.

How can I know the existence of vbCr (or other special characters such as CR, LF)?

Thanks.
Jan 13 '12 #1

✓ answered by Guido Geurs

Check the last character(s) with the "Asc" function.
Cr = 13
Lf = 10
CrLf=13+10

This is a test demo in VB6 with 2 textboxes and 4 commands

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.    Text1.Text = "ABC" & vbCr '13
  3.    Text2.Text = Asc(Right(Text1.Text, 1))
  4.    Call check
  5. End Sub
  6.  
  7. Private Sub Command2_Click()
  8.    Text1.Text = "ABC" & vbLf '10
  9.    Text2.Text = Asc(Right(Text1.Text, 1))
  10.    Call check
  11. End Sub
  12.  
  13. Private Sub Command3_Click()
  14.    Text1.Text = "ABC" & vbCrLf '13-10
  15.    Text2.Text = Asc(Mid(Text1.Text, Len(Text1) - 1, 1)) & " - " & Asc(Right(Text1.Text, 1))
  16.    Call check
  17. End Sub
  18.  
  19. Private Sub Command4_Click()
  20.    Text1.Text = "ABC"
  21.    Text2.Text = Asc(Right(Text1.Text, 1))
  22.    Call check
  23. End Sub
  24.  
  25. Private Sub check()
  26.    '§ check on CR and LF
  27.    If Asc(Mid(Text1.Text, Len(Text1) - 1, 1)) = 13 And _
  28.    Asc(Right(Text1.Text, 1)) = 10 Then
  29.       MsgBox "ends on CrLf"
  30.       Exit Sub
  31.    End If
  32.    '§ check on CR
  33.    If Asc(Right(Text1.Text, 1)) = 13 Then
  34.       MsgBox "ends on Cr"
  35.       Exit Sub
  36.    End If
  37.    '§ check on LF
  38.    If Asc(Right(Text1.Text, 1)) = 10 Then
  39.       MsgBox "ends on Lf"
  40.       Exit Sub
  41.    End If
  42.    '§ not found
  43.    MsgBox "ends on " & Right(Text1.Text, 1)
  44. End Sub
  45.  

1 2103
Guido Geurs
767 Expert 512MB
Check the last character(s) with the "Asc" function.
Cr = 13
Lf = 10
CrLf=13+10

This is a test demo in VB6 with 2 textboxes and 4 commands

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.    Text1.Text = "ABC" & vbCr '13
  3.    Text2.Text = Asc(Right(Text1.Text, 1))
  4.    Call check
  5. End Sub
  6.  
  7. Private Sub Command2_Click()
  8.    Text1.Text = "ABC" & vbLf '10
  9.    Text2.Text = Asc(Right(Text1.Text, 1))
  10.    Call check
  11. End Sub
  12.  
  13. Private Sub Command3_Click()
  14.    Text1.Text = "ABC" & vbCrLf '13-10
  15.    Text2.Text = Asc(Mid(Text1.Text, Len(Text1) - 1, 1)) & " - " & Asc(Right(Text1.Text, 1))
  16.    Call check
  17. End Sub
  18.  
  19. Private Sub Command4_Click()
  20.    Text1.Text = "ABC"
  21.    Text2.Text = Asc(Right(Text1.Text, 1))
  22.    Call check
  23. End Sub
  24.  
  25. Private Sub check()
  26.    '§ check on CR and LF
  27.    If Asc(Mid(Text1.Text, Len(Text1) - 1, 1)) = 13 And _
  28.    Asc(Right(Text1.Text, 1)) = 10 Then
  29.       MsgBox "ends on CrLf"
  30.       Exit Sub
  31.    End If
  32.    '§ check on CR
  33.    If Asc(Right(Text1.Text, 1)) = 13 Then
  34.       MsgBox "ends on Cr"
  35.       Exit Sub
  36.    End If
  37.    '§ check on LF
  38.    If Asc(Right(Text1.Text, 1)) = 10 Then
  39.       MsgBox "ends on Lf"
  40.       Exit Sub
  41.    End If
  42.    '§ not found
  43.    MsgBox "ends on " & Right(Text1.Text, 1)
  44. End Sub
  45.  
Jan 13 '12 #2

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

Similar topics

37
by: Tim Marshall | last post by:
From http://www.mvps.org/access/tencommandments.htm 9th item: Thou shalt not use "SendKeys", "Smart Codes" or "GoTo" (unless the GoTo be part of an OnError process) for these will lead you...
4
by: sundar_s1210 | last post by:
i have the following code in asp using vbscript replace(str,vbcrlf," ") replace(str,vbcr," ") replace(str,vblf," ") where str is any string i want to convert this code in asp.net using...
8
by: Guy | last post by:
Hi, I'm trying to run this code : strFileContentsHTML.Replace(vbLf, "<br>") strFileContentsHTML.Replace(vbCrLf, "<br>") strFileContentsHTML.Replace(vbCr, "<br>") It doesn't replace newline...
3
by: Terry Olsen | last post by:
I have a string that is approximately 600 characters. I need to divide up the string into 400 character chunks. I'm having trouble with using LastIndexOf. The following code returns a value of...
7
by: teo | last post by:
Hallo I need to extract a subtext from a text. The subtext must contain a given word. The subtext bounds are: vbCr (return) vbLf (new line) vbCrLf (return+new line)
5
by: Wilkesy | last post by:
Hi All, Im trying to finish off some coursework im doing. Ive finished the database, created all my forms and everything works perfectly, that was until i created a switchboard!!! Im using...
1
by: abprules | last post by:
Here's what I'm trying to do: I want to type in a combo box (search for a Contact) and if that contact is not in the list, pop up a message box asking the user if they want to add the contact. I've...
2
by: eazyone | last post by:
I can prevent a duplicate ID from being entered, but can't figure out how to go to that specific record. I keep getting an error message on: Me.Bookmark = rsc.Bookmark Its not opening and...
7
by: John Wright | last post by:
I have data coming into a serial port that I need to take action on. I have created a delegate to read the data from the port and put it into a text box. Once the data is read, I need to...
8
by: DAHMB | last post by:
The following codes works when Lines 2 and 3 are strings but when I change them to doubles it does not work. I believe my error lies in line 9 but I need help in fixing it. Thanks Dan ...
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: 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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.