-
Jul 31st, 2005, 01:27 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Replacements for vbCrLf, vbTab, etc
Recently stummbled on the issue of using a '.NET' replacement for the constants 'vbCrLf, vbTab', etc.
Figured out that vbCrLf = Environment.Newline, but others are not so easy. I have had a look at Wossnames' Char Initializer class (nice job! ), and it works well for creating other control characters.
Was this an oversight on M$ part, not providing a .NET equivalent for the Chr and Asc functions, do you think? (Is it still the same in V2005?)
-
Jul 31st, 2005, 01:35 PM
#2
Re: Replacements for vbCrLf, vbTab, etc
You can use the Convert function.
VB Code:
MessageBox.Show("Test" & Convert.ToChar(13) & "Test")
'"Test"
'"Test"
Edit: I think its more of a choice MS made to advance VB towards OOP and get away from the days of BASIC language.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jul 31st, 2005, 01:41 PM
#3
Re: Replacements for vbCrLf, vbTab, etc
Hers the Tab equilivalent.
VB Code:
MessageBox.Show("Test" & Convert.ToChar(9) & "Test")
'"Test Test"
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jul 31st, 2005, 01:47 PM
#4
Thread Starter
Fanatic Member
Re: Replacements for vbCrLf, vbTab, etc
Thanks Rob, I didn't know about the Convert function.
I would have to say that I am totally new to all things VB, so am not burdened with any problems upgrading from VB6. It is all new to me!
-
Jul 31st, 2005, 01:53 PM
#5
Re: Replacements for vbCrLf, vbTab, etc
I know its hard for VB6 programmers to convert to vb.net as it was and still is to a point for me too. Seems if you have no VB6 experience your better off because your not trying to convert old vb6 habits, which usually aren't the best, to new vb.net.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jul 31st, 2005, 02:02 PM
#6
Re: Replacements for vbCrLf, vbTab, etc
ControlChars.Tab, ControlChars.NewLine, ControlChars.Quote
These come from the VisualBasic namespace but not from the Compatibility namespace. NOTE: You can't unreference the VisualBasic namespace in a VB application nor is it bad.
In C# you could use \r\n or \t.
Last edited by Edneeis; Jul 31st, 2005 at 02:12 PM.
-
Jul 31st, 2005, 02:08 PM
#7
Re: Replacements for vbCrLf, vbTab, etc
Convert comes from the System namespace so I think its best to use those since it is more relative to .NET.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jul 31st, 2005, 02:12 PM
#8
Re: Replacements for vbCrLf, vbTab, etc
Ed, isnt that the same as JavaScript? Makes sense ince C# is very similar to C++ and JavaScript.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jul 31st, 2005, 09:08 PM
#9
Re: Replacements for vbCrLf, vbTab, etc
The easiest way to create characters for things like Tab, etc. is to use ControlChars, as suggested in the VS help. If you don't like VB Runtime constants then the next easiest way is to combine Rob's suggestion with the Keys enumeration. The Keys enumeration gives a descriptive name to ASCII and Unicode codes so you don't need to remember the codes yourself. To get the Tab character you just use Convert.ToChar(Keys.Tab). Intellisense will give you a list of the members of the enumeration so if you aren't sure what you're looking for you can type "keys." and browse the listing.
Originally Posted by RobDog888
Convert comes from the System namespace so I think its best to use those since it is more relative to .NET.
I guarantee you that the overwhelming majority of C# developers will use the escaped C characters rather than using the Convert class, so ControlChars is no more language-specific than that.
-
Aug 1st, 2005, 11:22 AM
#10
Thread Starter
Fanatic Member
Re: Replacements for vbCrLf, vbTab, etc
To get the Tab character you just use Convert.ToChar(Keys.Tab).
Thanks JM, that's cool.
It appears there are many ways to skin many cats in .NET!
-
Aug 1st, 2005, 05:51 PM
#11
Re: [RESOLVED] Replacements for vbCrLf, vbTab, etc
Note that Convert.ToChar(Int32) and Convert.ToInt32(Char) work the same as ChrW() and AscW(). The Keys enumeration also has the Return (CR) and LineFeed (LF) members.
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
|