holemania
asked on
VB.Net - Windows UserName index and length error
I have a Vb.Net application that I want to track the user who logs into Windows. I am keeping this information in a table that has only 8 characters long. When I do the following, I am getting the error.
I did a length and the name "blakie" is 13 characters long. So is there something that is padding in that string? I also tried to trim, but it's still come up as 13 characters long.
Index and Length must refer to a location within the string. Parameter name: length
Dim strUser String = System.Environment.Username.Substring(0,8).ToUpper
I did a length and the name "blakie" is 13 characters long. So is there something that is padding in that string? I also tried to trim, but it's still come up as 13 characters long.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Looks like when I add the "If" statement to evaluate the length, the error went away. Thanks.
ASKER
Open in new window