King Erik I Posted April 19, 2004 Posted April 19, 2004 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 Quote
King Erik I Posted April 19, 2004 Author Posted April 19, 2004 Got it :-D Label2.Text = Mid(Format(System.DateTime.Now, "M"), 1, 3) Quote
Administrators PlausiblyDamp Posted April 19, 2004 Administrators Posted April 19, 2004 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 Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
King Erik I Posted April 20, 2004 Author Posted April 20, 2004 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! Quote
Administrators PlausiblyDamp Posted April 20, 2004 Administrators Posted April 20, 2004 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
King Erik I Posted April 20, 2004 Author Posted April 20, 2004 aah ok :-) The reason I've posted that code was becouse my collegae has programming experience in VB6.... I am pretty new to VB... ;-) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.