Results 1 to 11 of 11

Thread: get compiled type

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    Guayaquil, Guayas, Ecuador
    Posts
    87

    get compiled type

    How can i get the compiled type, to show at runtime if the program is in release mode or in debug mode
    thanks

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    There is a built-in compilation constant called DEBUG
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, _
    2.                               ByVal e As System.EventArgs) _
    3.                               Handles Button1.Click
    4.  
    5. #If DEBUG Then
    6.         MsgBox("Debug mode!")
    7. #Else
    8.         MsgBox("Release mode!")
    9. #End If
    10.  
    11.     End Sub
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    Guayaquil, Guayas, Ecuador
    Posts
    87

    ?

    What does thous # means before the if then else

  5. #5
    Member
    Join Date
    Apr 2004
    Location
    Millbrae, CA
    Posts
    48

    Re: ?

    Originally posted by Antonio Begue
    What does thous # means before the if then else

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    Guayaquil, Guayas, Ecuador
    Posts
    87

    ?

    #If DEBUG Then
    MsgBox("Debug mode!")
    #Else
    MsgBox("Release mode!")
    #End If

    thous #

  7. #7
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Its conditional compilation. The stuff in the #If section will only be compiled into the assembly if the condition or variable (DEBUG in this case) is defined and is True. Otherwise the code in the #Else portion is compiled in.

    Try it for yourself...
    VB Code:
    1. #If QWERTY Then
    2.     MsgBox("Poop!")
    3. #End If

    Put that in the Load event of your form, and see if you see a msgbox. I bet you won't.

    Then, put this at the top of your class...
    VB Code:
    1. #Const QWERTY = True

    and run it again. I'll bet you see the msgbox this time.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    Guayaquil, Guayas, Ecuador
    Posts
    87
    ok but why this work #IF DEBUG then and this not if DEBUG then
    and where can i get a list of constants like DEBUG

  9. #9
    Member
    Join Date
    Apr 2004
    Location
    Millbrae, CA
    Posts
    48
    Originally posted by Antonio Begue
    ok but why this work #IF DEBUG then and this not if DEBUG then
    and where can i get a list of constants like DEBUG
    Now I understand! That's very cool... you learn something everyday.

    When you write #If the intellisense takes over with a list of constants already defined.

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    Guayaquil, Guayas, Ecuador
    Posts
    87
    well I think it is not only that you get a pre defined constants list, I think that the false part does not get compiled so you reduce the runtime proces

  11. #11
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Originally posted by crptcblade
    There is a built-in compilation constant called DEBUG
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, _
    2.                               ByVal e As System.EventArgs) _
    3.                               Handles Button1.Click
    4.  
    5. #If DEBUG Then
    6.         MsgBox("Debug mode!")
    7. #Else
    8.         MsgBox("Release mode!")
    9. #End If
    10.  
    11.     End Sub
    Cool, thanks. I've been looking for that.
    This question was raised by Mr. Polite some time ago, and my only answer was the one above.
    I had read about a constant but I have not been able to find it...until now, that is...thanks.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

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