Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

how do I set the max length of a string??

 

Becouse I have a string which is filled with the name of the month and I just want the first three letters.... :confused:

 

Greetings

  • Administrators
Posted

You really should avoid the VB6 compatability functions in .Net the following uses the .Net way.

Label2.Text = System.DateTime.Now.ToString("M").Substring(0, 3)

 

however if you just wanted to get the day of month then why not use.

Label2.Text = System.DateTime.Now.Day

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

What is the advantage of the piece of code what you've posted...

 

Label2.Text = System.DateTime.Now.ToString("M").Substring(0, 3)

 

... against mine? I am just a starting VB programmer and learning a lot at this moment....

 

Any suggestions are welcome!

  • Administrators
Posted

Functions like Mid and Format are really only there for backwards compatability with VB6 and will result in more work for your program as the compatability functions call the real .Net ones behind the scenes.

If you ever decide or have to move to C# then the VB6 functions will be unavailable - if you use the code I suggested then the C# version is almost identical.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...