Wrox Programmer Forums
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 29th, 2004, 05:41 PM
Registered User
 
Join Date: Apr 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB.NET question

What does Char = {ControlChars.Tab, " "c} mean? It is in a sample program I have and would like to know what it means.

The full line is

Dim separators() As Char = {ControlChars.Tab, " "c}

Thanks
 
Old May 1st, 2004, 08:48 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

1) separators() indicates this variable is an Array.
2) The {...} is the syntax for an explicitly created Array.
3) " "c is shorthand for casting a space (" ") to a char

In this case, the code is creating a two dimensional array. This same line of code could be written in three lines like this:

Dim separators(1) As Char
separators(0) = ControlChars.Tab
separators(1) = " "c

Peter
-------------------------
Work smarter, not harder
 
Old May 1st, 2004, 01:16 PM
Registered User
 
Join Date: Apr 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What does the ControlChars.Tab section mean??
 
Old May 1st, 2004, 10:42 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It is the .net object representing the Tab character.
 
Old May 2nd, 2004, 01:42 PM
Registered User
 
Join Date: Apr 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So, in short, does
Dim separators() As Char = {ControlChars.Tab, " "c}

mean "translate all tab characters to space characters"?
 
Old May 2nd, 2004, 11:51 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

No, it means "create a one dimensional array with two elements, one containing a tab and the other a space".
 
Old May 3rd, 2004, 04:58 PM
Registered User
 
Join Date: Apr 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Forgive me, I am trying to learn VB.NET as best as I can. Here is a code snippet. If you could give me a quick synopsis (in a nutshell) what the code means, I think it will greatly help me.

Thanks

                If (oneline.StartsWith("Public Class ")) Then
                    nameStart = oneline.IndexOf("Class ") + 6
                    Dim names() As String
                    Dim separators() As Char = {ControlChars.Tab, " "c}
                    names = oneline.Substring( _
                    nameStart).Trim().Split(separators)
                    Dim className As String = names(0).Trim()
                    m_classNames(m_classCount) = className
                    m_classCount += 1
                End If
 
Old May 4th, 2004, 07:48 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It looks like this code is parsing a code file and extracting class names from any class declarations contained in the code.

First it asks: Does "oneline" start with with "Public Class "
If so, then it executes all of the code in that if block.
- Get the character location of "Class " and add 6
- Instantiate a couple arrays (one string, one char)
- Set the "separators" array to contain 2 elements (the tab character and a space)
- Set "names" to contain elements based on the result of splitting the sub string of "oneline" (starting at "nameStart") into pieces based on either the tab or space character.
- Instantiate and set "className" to the first element of the "names" array.
- Set the class/module scope array "m_classNames" element located at index "m_classCount" to the value in "className"
- Increment the class/module scope variable "m_classCount" by 1

The result of something like is that for the given "oneline" value of:

    Public Class MyClass

you'll end up with "className" equaling "MyClass" and the counter will increment.

How are you trying to learn VB.NET? Have you got an intro to VB.NET book yet? This seems like a round-about way of learning if you asked me.
 
Old May 4th, 2004, 05:27 PM
Registered User
 
Join Date: Apr 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using a non Wrox book. (Bad Logan, bad Logan). It's by Micro$oft and it has you type in code, but sometimes they don't fully explain the lines of code. Is there a better Wrox book I could use? I need VB.NET and C# training.





Similar Threads
Thread Thread Starter Forum Replies Last Post
VB and ASP.NET question RomeyRome BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 2 December 20th, 2007 07:20 PM
vb.net realeted question monika.vasvani ASP.NET 1.0 and 1.1 Professional 1 October 15th, 2007 08:29 AM
VB.net question farsfar2 VS.NET 2002/2003 1 March 31st, 2005 06:29 AM
VB.Net question on Windows VB.Net datagrids dmsousa VS.NET 2002/2003 1 January 19th, 2005 02:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.