|
-
Jul 6th, 2004, 09:09 AM
#1
Thread Starter
Fanatic Member
Creating a string 53 # characters long **RESOLVED**
In VB6 I could create a string using the string word
Does anyone know the equivalent for VB.NET
Thanks
Last edited by davidrobin; Jul 7th, 2004 at 02:39 AM.
-
Jul 6th, 2004, 11:45 AM
#2
Hyperactive Member
Perhaps something like:
Dim str As String = ""
str = str.PadRight(53, "#"c)
Live long and prosper (Mr. Spock)
-
Jul 6th, 2004, 11:53 AM
#3
Hyperactive Member
This is a single line example
VB Code:
Dim sValue As New String("#"c, 53)
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 6th, 2004, 12:24 PM
#4
Hyperactive Member
I didn't know this method. Good to know!
Live long and prosper (Mr. Spock)
-
Jul 7th, 2004, 02:39 AM
#5
Thread Starter
Fanatic Member
Originally posted by CyberHawke
This is a single line example
VB Code:
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.
-
Jul 7th, 2004, 05:28 AM
#6
Hyperactive Member
probably because "Intelisense" should be renamed to "Intelinonsense"
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 7th, 2004, 08:52 AM
#7
PowerPoster
Originally posted by CyberHawke
This is a single line example
VB Code:
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.
-
Jul 7th, 2004, 08:58 AM
#8
Hyperactive Member
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!

-
Jul 7th, 2004, 09:19 AM
#9
PowerPoster
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.
-
Jul 7th, 2004, 09:23 AM
#10
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|