none
creating a text object

Answers

  • There are many ways to create a string, for example:

    Dim s As String = ""

    What may have tripped you up is that Strings don't have a argument-less constructor, which means that you can't do something like:

    Dim newString As String = New String() ' <-- Error! Can't do this!

    Since strings are immutable (you can't change a string after it has been created) it doesn't make sense to have an empty constructor.

    Best regards,
    Johan Stenberg
    Sunday, August 07, 2005 5:29 PM
    Moderator

All replies

  • hi,

    what do you mean with creating a textobject.

    Do you mean:

    - a string?
    - a label?
    - a textbox?
    - a richtextbox?
    Sunday, August 07, 2005 1:21 PM
    Moderator
  • a string
    Sunday, August 07, 2005 2:28 PM
  • There are many ways to create a string, for example:

    Dim s As String = ""

    What may have tripped you up is that Strings don't have a argument-less constructor, which means that you can't do something like:

    Dim newString As String = New String() ' <-- Error! Can't do this!

    Since strings are immutable (you can't change a string after it has been created) it doesn't make sense to have an empty constructor.

    Best regards,
    Johan Stenberg
    Sunday, August 07, 2005 5:29 PM
    Moderator
  • maybe I should have said:Can you make text act like a control?

    Monday, August 08, 2005 2:02 AM
  • For read only text, use a label control and set its text property.
    For read/write text, use a textbox control and set its text property.

    Best regards,
    Johan Stenberg

    Monday, August 08, 2005 2:11 AM
    Moderator
  • Mr. Stenberg;

     

    I have come across the syntax,

    Dim NewString As [String] = [String].Empty

    How does this syntax change the 'standard' way of decalring a string variable?  Is this related to a 'string object'?

    Dim NewString as String = String.Empty

     

    Wednesday, July 26, 2006 9:42 PM
  • By putting [ and ] you can escape the name between them. In this case, since string is a built in keyword in Visual Basic .NET, the compiler would have treated it as the keyword string instead of the type name String.

    In this particular case (assuming that you are Importing the System namespace) they just happen to mean the same thing (a string in Visual Basic maps to the System.String class in the .NET framework.

    For a more informative example, see:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbls7/html/vblrfvbspec2_2.asp

    Best regards,
    Johan Stenberg

    Friday, July 28, 2006 6:05 PM
    Moderator