Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8
This is the forum to discuss the Wrox book Visual Basic 2008 Programmer's Reference by Rod Stephens; ISBN: 9780470182628
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 27th, 2011, 01:44 PM
Registered User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Location: Alabama
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Default formatting strings and string.format

Just got my book a few hours ago. I was unable to find any subject matter
concerning the use of string.format("{o}",vbCrLf) as an example.
I was looking for the explanation on using the place holders such as {0}.

Perhaps I could not find it yet. Also need information on using the serial port if it is covered.

I am looking forward to using the book in my quest to gain enough knowledge to use VB.NET for various projects.
I look forward as well to using the forum for assistance and knowledge.

Years ago I was able to use a WROX book on HTML and it helped much.
That was the reason I purchased this book.

Best Regards to all.
Reply With Quote
  #2 (permalink)  
Old July 27th, 2011, 03:34 PM
Rod Stephens's Avatar
Wrox Author
Points: 2,999, Level: 22
Points: 2,999, Level: 22 Points: 2,999, Level: 22 Points: 2,999, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 601
Thanks: 1
Thanked 84 Times in 83 Posts
Default

That's covered briefly in Appendix Q, "Other Format Specifiers" on page 1105-6.

The quick explanation is that the method replaces the placeholders with the parameters that follow. For example:

Code:
Dim txt As String = String.Format("There are {0} players", num_players)
If num_players is a variable holding the value 9, then this builds the string:

Quote:
There are 9 players
You can also add an alignment and format specifier if you like.

Let me know if you have specific questions about this. It isn't covered too much in the book. Often it's just as easy to compose strings using concatenation instead of String.Format.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)

Last edited by Rod Stephens; July 27th, 2011 at 03:46 PM.
Reply With Quote
The Following User Says Thank You to Rod Stephens For This Useful Post:
eightbits2011 (July 28th, 2011)
  #3 (permalink)  
Old July 28th, 2011, 11:00 AM
Registered User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Location: Alabama
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Thanks so much for the quick reply.
Yes, I agree, the examples are sparse on this particular subject. I was hoping for a lot of example(s). I was looking for examples that covered
the formating of the placeholders and the results.

I agree that the just doing concatenate techniques will also do the job in most cases .

Considering that using VB.NET is relatively new to me, I wanted to insure that I have an understanding of using string.format.
It seems similar to using printf (C language) that I have some experience with.

All on all , I think the book will assist my goal to become knowledgeable in using VB.NET.

Also, I think I need to learn to use modules but did not see a lot of
examples on doing this.

Once again, thank you for the reply.
Reply With Quote
  #4 (permalink)  
Old July 28th, 2011, 12:40 PM
Rod Stephens's Avatar
Wrox Author
Points: 2,999, Level: 22
Points: 2,999, Level: 22 Points: 2,999, Level: 22 Points: 2,999, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 601
Thanks: 1
Thanked 84 Times in 83 Posts
Default

Yes, String.Format is a lot like printf (or probably really sprintf). The time I probably use it most is when I want to align things in columns.

Modules are pretty easy. They're simply code like global variables and routines that sits out there for any part of the program to use. The only really different thing is that code modules don't have any associated class. In contrast, C# doesn't have code modules so every piece of code must be in a class. To get a similar effect, you create a class (often called Globals or something similar) and give it static (shared) members so all of the rest of the code can use it without instantiating the class.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
The Following User Says Thank You to Rod Stephens For This Useful Post:
eightbits2011 (July 30th, 2011)
  #5 (permalink)  
Old July 30th, 2011, 02:23 PM
Registered User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Location: Alabama
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Thanks. Where in the book is the best place to get up to speed on
using modules and incorporating modules into new or existing projects?

Best Regards.

Last edited by eightbits2011; July 30th, 2011 at 02:23 PM. Reason: typo
Reply With Quote
  #6 (permalink)  
Old July 30th, 2011, 03:10 PM
Rod Stephens's Avatar
Wrox Author
Points: 2,999, Level: 22
Points: 2,999, Level: 22 Points: 2,999, Level: 22 Points: 2,999, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 601
Thanks: 1
Thanked 84 Times in 83 Posts
Default

Chapter 17, "Subroutines and Functions," may be a good place to start. But it's so easy there isn't too much coverage.

Just open the Project menu, select Add Module, give it a name, and click OK. Then add code to the module. If you add a public subroutine, function, or variable to the module, then any code in the project will be able to use it.

It's that easy.

Give it a try and let me know if you have problems.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
The Following User Says Thank You to Rod Stephens For This Useful Post:
eightbits2011 (July 31st, 2011)
  #7 (permalink)  
Old July 31st, 2011, 10:08 AM
Registered User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Location: Alabama
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Default

OK, I will continue to look at this. It seems this is an important feature
of using VB.NET.
Is there any simple examples on using a module from a form ?
As you might be able to tell, the inner workings of VB.NET are still
new to me.

I do thank you for your assistance.
Going through the book, there are many subjects covered, and I will
continue to learn from this book.
I already have four additional VB 2008 books as well.

Best Regards

Last edited by eightbits2011; July 31st, 2011 at 10:09 AM. Reason: typo
Reply With Quote
  #8 (permalink)  
Old July 31st, 2011, 10:40 PM
Rod Stephens's Avatar
Wrox Author
Points: 2,999, Level: 22
Points: 2,999, Level: 22 Points: 2,999, Level: 22 Points: 2,999, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 601
Thanks: 1
Thanked 84 Times in 83 Posts
Default

You can download an example at:

Write a subroutine in a code module that scales controls without moving them in Visual Basic .NET.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
formatting dates back to Mysql date format melkin Classic ASP Professional 1 February 19th, 2008 12:58 PM
String formatting MargateFan XSLT 4 May 5th, 2006 04:54 AM
formatting strings / dates clandestine XML 3 June 22nd, 2005 09:52 AM
RegExp looping for multiple strings in string interrupt Javascript How-To 2 June 20th, 2005 05:37 AM



All times are GMT -4. The time now is 03:21 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.