Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
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 September 19th, 2005, 10:41 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default What is the VB .NET replacement for VB6 String()?

What is the VB .NET replacement for the VB6 String() function?

(This function takes 2 arguments:
Code:
   Function String(Number As Long, Character) As String
The return value is a string of characters specified by the Character argument, repeated Number times.
String(4, "O") returns "OOOO".
String(4, 65) returns "AAAA".)
 
Old September 20th, 2005, 06:12 AM
Authorized User
 
Join Date: Jun 2003
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The String object constructor in vb.net has 3 overloads, one of which is similar to the VB6 function

Try something like

  Dim myRepeatedCharacter As String
  myRepeatedCharacter = New String("A", 4)

or

  Dim myRepeatedCharacter As String = New String("A", 4)
 
Old September 20th, 2005, 11:28 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I’m trying to put together:
Code:
MATERIAL/NOMEN CHECK          TIME: 07:55:44 DATE: 07/20/05
ITEM NO  STD NDX          FIELD       MATERIAL LIST     PART LIST
___________________________________________________________________
This is going into a file. So I have
Code:
With <a stream writer>

  .WriteLine("MATERIAL/NOMEN CHECK" & Space(10) & "TIME: " & Format(Now, "HH:NN:SS") & . . .
  .WriteLine("ITEM NO  STD NDX" & Space(...) & " . . . "

  ' Then here I want something like:
  .WriteLine(String(131, "_"))

End With
I suppose I could write a function of my own that wraps what you
suggested—and I will if there’s no other way. But is there another
way—a replacement for VB6’s String()?
 
Old October 6th, 2005, 01:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

As gcianfanelli said, the string constructor will do what you want.

Try
Code:
    .WriteLine(new String("_", 131))
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old November 4th, 2005, 11:46 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

What .NET required of me was:
Code:
     .WriteLine(New String("-"c, 131))
because of the warning (with "-" underlined with a squiggle) “Option Strict On disallows implicit conversions from 'String' to 'Char'.”

Thanks.





Similar Threads
Thread Thread Starter Forum Replies Last Post
VISTA NetSend Replacement in VB? Ron Howerton VB How-To 1 April 13th, 2007 01:46 AM
Consume VB6.0 WebService in ASP.NET using VB.NET pinkarc .NET Web Services 1 March 5th, 2007 08:19 AM
vb6 to vb.NET jorgefejr VB.NET 2002/2003 Basics 2 October 26th, 2006 05:05 AM
Should I go VB.NET or VB 2005 from VB6? HB Visual Studio 2005 1 December 9th, 2005 03:13 AM
What is the VB .NET replacement for VB6 String()? BrianWren VB.NET 0 September 19th, 2005 11:05 AM





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