Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics 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 October 13th, 2006, 04:31 AM
Registered User
 
Join Date: Oct 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using the padRight-method

Hi,

I would like to use the padRight-method in a visual basic file (Excel VBA).

The program I wrote manipulates curve data and then exports that data (including comments, etc.)
to a text file.

The comments (5 comment lines in total) are being typed into an input-box and the values are
being stored as a string in an array called comments(5) .

Since the text file is supposed to be used as an input file of a simulation software, the text can only be
written within the first eighty columns. Therefore, I need the text of the comments to be left-alligned
and the space occupied by the text in the text file should not exceed 70 characters.
The padright-method seem to be the perfect solution for that task, but I can´t get it to work.

The fragments of the code look like this:

----------------------------------------------------------------

Dim Comments(5) As String

Comments(1) = Comments_TB_Name
Comments(2) = Comments_TB_Comment1
Comments(3) = Comments_TB_Comment2
Comments(4) = Comments_TB_Comment3
Comments(5) = Comments_TB_Comment4

' Comments_TB_Comment1,...Comments_TB_Comment4 are the comments that were
read from the input-box!

...

totalWidth

For i = 1 To 5

Comments(i) = Comments(i).PadRight(totalWidth)
Print #1, "$--- - "; Comments(i); " ---"

Next i
----------------------------------------------------------------

The function I used is:

Dim totalWidth As Integer
Dim paddingChar As String

Public Function PadLeft(ByVal totalWidth As Integer, _
ByVal paddingChar As Char) As String

End function

----------------------------------------------------------------

It would be great, if someone could help me and tell me how to apply the padright-method in an appropriate manner.

Thank you very much in advance.

Dirk







Similar Threads
Thread Thread Starter Forum Replies Last Post
About Method VeradisSanthanam ASP.NET 2.0 Basics 1 June 19th, 2007 06:52 AM
method amit_p_patel VB How-To 2 May 25th, 2007 01:46 AM
Why is this method placed in filip BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 1 August 25th, 2006 09:40 PM
Best method rastham SQL Server 2000 2 February 16th, 2006 12:59 AM
Method StanArtis BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 December 6th, 2004 06:09 AM





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