Wrox Programmer Forums
|
BOOK: Visual Basic 2005 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2005 Programmer's Reference by Rod Stephens; ISBN: 9780764571985
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2005 Programmer's Reference 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 May 2nd, 2006, 08:21 AM
Authorized User
 
Join Date: Mar 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Padding Strings

Well I am trying to use string.padRight to set a bunch of strings to the length of the longest. But the strings are not getting any right spaces. Here is the code that is doing nothing. I have checked the reference guide and this looks like it should pad the string to the right with the value in the brackets but it doesn't. texturelength is 32 in my test


Code:
Dim padTexture As String = texture
padTexture.PadRight(texturelength + 2)


Any pointers much appreciated

Jon Masterson
__________________
Jon Masterson
 
Old May 2nd, 2006, 03:02 PM
Authorized User
 
Join Date: Mar 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK I figured it out. First I thought it was because I used a For Each...Next loop to iterate a set. Then I realized that I was not trying to write to the enumerated value in any case.

Finally it dawned on me that there needs to be an Assignment

Code:
padTexture = padTexture.padRight(textureLength + 2)
My fault but somehow I got the mindset that the compiler would throw out something that should be part of an assignment - apparently not even with Option Strict on.







Jon Masterson
 
Old May 3rd, 2006, 07:50 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

You're right. All of the similar String methods PadRight, PadLeft, Substring, Trim, Replace, etc. return a value, they don't modify the value of the String you're working with.

Some of the MVPs have talked about raising a warning if you don't use a function's return value. I think the concensus was that someone will be confused either way.


Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm
 
Old May 3rd, 2006, 10:55 AM
Authorized User
 
Join Date: Mar 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 
Quote:
quote:Some of the MVPs have talked about raising a warning if you don't use a function's return value. I think the concensus was that someone will be confused either way.


Me for one :D:D

Jon Masterson





Similar Threads
Thread Thread Starter Forum Replies Last Post
Padding Zeros jmss66 Classic ASP Basics 5 January 28th, 2008 07:38 PM
IE not displaying padding properly :-( lpcrooks CSS Cascading Style Sheets 0 November 17th, 2006 01:08 AM
"Padding" a value in XSL francislang XSLT 1 September 3rd, 2004 07:56 AM
Add padding zero to year Genuine Beginning PHP 2 August 6th, 2004 07:09 AM
padding problem anshul HTML Code Clinic 5 July 24th, 2004 11:11 PM





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