Results 1 to 10 of 10

Thread: Creating a string 53 # characters long **RESOLVED**

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982

    Creating a string 53 # characters long **RESOLVED**

    In VB6 I could create a string using the string word
    VB Code:
    1. string(53,'#')
    Does anyone know the equivalent for VB.NET

    Thanks
    Last edited by davidrobin; Jul 7th, 2004 at 02:39 AM.


    Things I do when I am bored: DotNetable

  2. #2
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    Perhaps something like:

    Dim str As String = ""
    str = str.PadRight(53, "#"c)
    Live long and prosper (Mr. Spock)

  3. #3
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    This is a single line example
    VB Code:
    1. Dim sValue As New String("#"c, 53)
    Whadayamean it doesn't work....
    It works fine on my machine!

  4. #4
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    I didn't know this method. Good to know!
    Live long and prosper (Mr. Spock)

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    Originally posted by CyberHawke
    This is a single line example
    VB Code:
    1. Dim sValue As New String("#"c, 53)
    Thats really strange because when I tried typing a variable declaration like that and typed the open bracket the intellisence didn't kick in.
    I have just tried it now and it did.
    I was sure there was some kind of feature like that somewhere.

    Many Thanks.


    Things I do when I am bored: DotNetable

  6. #6
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    probably because "Intelisense" should be renamed to "Intelinonsense"
    Whadayamean it doesn't work....
    It works fine on my machine!

  7. #7
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Originally posted by CyberHawke
    This is a single line example
    VB Code:
    1. Dim sValue As New String("#"c, 53)
    OK. That works fine, but can you tell me why it needs "New"? (I know it does)

    What is the difference between:

    Dim strTest As New String

    and

    Dim strTest As String

    (I have both Option Strict and Option Explicit set to On.)
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  8. #8
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    Ok, you need to understand that in .NET "EVERYTHING" is an object, even datatypes. so when you declare an instance variable of type String, just as with any other object, you need to instantiate it by declaring it as new. This is only true when you are doing an initial population of the string with a repeating set of characters. In all other instances, VB will set the object reference for you automatically, one of the reasons that VB developers have been shunned by the rest of the developer community for so many years and also why VB has been labeled a "toy" language in the past.
    Whadayamean it doesn't work....
    It works fine on my machine!

  9. #9
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi cyberhawke,

    Many thanks.

    By the way, if VB has been described as a "Toy language" I wonder what the comment is about my learning ground -
    dBase III plus?
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  10. #10
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    VB was described as a "Toy Language" in the past by C/C++ developers and such because it wrapped most of the low-level work that they had to do by hand. While with .NET much of that is still true, you do have more access to low-level functions as well as full access to full OOP development and multi-threading. With the advent of VB.NET, it is no longer considered a toy language.
    Whadayamean it doesn't work....
    It works fine on my machine!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width