Results 1 to 10 of 10

Thread: Why Won't This Code Work?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Toronto, Ontario, Canada
    Posts
    275

    Why Won't This Code Work?

    TextBox7.Text = (Environment.OSVersion)

    Why Won't That Work? I'm only 12 and new to vb.net

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    VB Code:
    1. TextBox7.Text = (Environment.OSVersion.ToString())

  3. #3
    Member HumanCompiler's Avatar
    Join Date
    Dec 2002
    Location
    Decatur, IN USA
    Posts
    52
    As long as you don't have Option Strict on, this will work.

    VB Code:
    1. TextBox7.Text = Environment.OSVersion
    -Erik Porter
    .NET MVP

  4. #4
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    ...but you'll always have Option Strict On

  5. #5
    Member HumanCompiler's Avatar
    Join Date
    Dec 2002
    Location
    Decatur, IN USA
    Posts
    52
    It's not the default...Option Explicit is on by default, but not Option Strict
    -Erik Porter
    .NET MVP

  6. #6
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    i didn't say anything about a default, just mentioning that it's good practice...

  7. #7
    Member HumanCompiler's Avatar
    Join Date
    Dec 2002
    Location
    Decatur, IN USA
    Posts
    52
    writing perfect code is good practice too, but we all don't usually quite hit that mark

    I, myself, never put Option Strict On and I've never had any bugs that I couldn't find because of it being Off...probably depends on the person.
    -Erik Porter
    .NET MVP

  8. #8
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    I hear ya, unfortunately a minor suggestion of turning Option Strict On is doable and is a far cry from suggesting to someone "write perfect code", the original poster is 12 years now, may as well get a head start on good programming practices, that's all. And I wasn't implying that Option Strict has anything to do with bugs, in a team environment it can make code a lot cleaner and easier to follow.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Toronto, Ontario, Canada
    Posts
    275
    I can use all the help I can get.

  10. #10
    Member HumanCompiler's Avatar
    Join Date
    Dec 2002
    Location
    Decatur, IN USA
    Posts
    52
    Then go ahead and use it, because as suggested, it will probably help you, I was just saying that it doesn't really help me personally
    -Erik Porter
    .NET MVP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width