????? ?? Visual Basic 2005 ?? Visual Basic ??? ???? ???? ?? ??? ????????

???? ?????? ???? ??????
???? ID: 313417 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
?? Microsoft Visual Basic 6.0 ??????? ?? ??? ????, ????? 161153.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ???? ???? ???? ?? ????? ??????? ?? ????? ???? ????????? ???? ?? ??? ?? ??????? Microsoft ??? ?????? ??????? ?????? ?? ???? ??? ??????? ?????? ???? ?? ??? ?? ?? ??????? ?? ????? ?? ???? ??? ??? ?????????, ????????? ????? ?? ????? ?? ??? ?? ???????? ????????? ??????? ???? ?? ???? ?? ??????? ?? ???? ?? ??? ??? ??? ??????????????? ???????? ??? ?????? ??????? ??????

??????????

????? ???? ???????? ?????????, ?????????? outlines, ??????? ???? ??????, ?? ???? ???? ???:
  • Microsoft Windows 2000 ?? Microsoft Windows XP
  • Microsoft Visual Basic 2005 ?? Visual Basic.???
?? ??? ?? ?? ?? ????????? ?? ??? ?????? ??? ????? ?? ???? ?????

????? ?? ?????

???? ?? ????? ????? ?? "???? ???? ?? ??? ?? ????? ?????" ??? ??? ??? ????? ?? ???????? ???? ??? ????????? ????????? ?? ???? ??? ??????? ?????? ????? ?? ??? ???? ???? ?? ????? ???? ?? ?????????

?? ????????? ????? ??, ?? ?? ???? ???? ?? ????, ?? ??? ????? ?? ??? ???????? ???? ?? ??? ??? ????? ?????? ?? ??? ????? ?? ???? ??? malfunctions, ?? ???????? ??? ??????? ?????? ???? ?? ???? ???????? ??? ??, ???? ???? ?? ????? Microsoft Visual Studio ?? ?????? ????? ??? ????? ?????? ????? ?????? (IDE)?

?? ???? ?? ????? ?? ????? ?????? ?? ??? ????? ??? WriteLine ???? ?? ????? ???? ?? ?????????, ??? ?????? ??? ?? ?? ????? ?????? ?? ??? ?? ???? ?? ????? ???? ???, ?? ???????? ????? ????? ???? ?? ?? ??? ???? ?? ????? ??? ???????

???? ?????? ?? Assert ???? ?? ????? ???? ???, ?? ?????? ????? ????? ???? ???? ????????? ?? ????????? ???? ?? ???? false ?? ??? ?????????? ???? ??? ???? ????? ????? ????? ??? ?? ????? ????? ??????????? ????? ????? ?????, ????????? ??? ?? Debug.Assert ??? ???? ????? ???? ??? ???? ????? ????? ?? ????? ?? ???:
  • ?????? ????: ????????? ????? ?? ????
  • ???: ?????? ????: ????????? ???? ??? ??? ??? ???? ???
  • ????? ? ???: ????????? proceeds.
?????????? ????????? ?? ???? ?? ???? ??? ?? ???? ?? ?? ????? ???? ???? ???? ?? ???? ????

???? ?? ???? ???? ?? ?????? ?????? ????? ?? ????? ???????? ?? ??? ?? ????????? ?? ???? ???? ???? ???? ??? ?????? ?????? ?????????? ???????? ?? ?? ?????? ??? ???????? ?????? ???????? ???? ?????? ?? ??????? ???? ?? ?? ?????? ????????? ?????? ???? ?? ??? directs. ???? ???? ????? ???? ?? ??? ?? ?????? ???????? ?? ?????? ??? ?? ?????? ??????? ???? ??? ?????? ?????????? ????????? ???? ?? ??? TextWriterTraceListener ???? ?? ????? ????? ?? ???? ????????????? ?? ?????? ?? ?? TextWriterTraceListener ???? ?? ??? ?????? ????????? ?? ???? ???? ??? ??????? ?????? ???????? ????? ???:
  • System.Console.Out ??? ?? ????? ????? ??????
  • System.IO.File.CreateText("FileName.txt")) ??? ?? ????? ?? ??? (. txt) ??????
???? TextWriterTraceListener ???????? ????? ?? ???, ?? ?????? ???? ??????? ???? ?? ??? Debug.Listeners ?????? ?? ??? ???????? ?????? ?????

???? ???? ?? ??? ?? ????? ?????

  1. Visual Basic 2005 ?? Visual Basic ?? ????? ?????NET conInfo ???? ?? ?? ????? ????????? ????????? ????? ?? ???? ????????? ?????? ???? ?? ??? Module1 ???? ?? ????????? ??????? ????? ??? ?? ?????????
  2. ?? ?? ???? ??? ??????? ???????? ???? ?? ??? ???? ???? ?? ??? ?? ??????, ??? ?????????? ??? ??????:
    Dim sProdName As String = "Widget"
    Dim iUnitQty As Integer = 100
    Dim dUnitCost As Decimal = 1.03
    					
  3. ????? ???? ??, ?? ???? ?? ??? ??? ????????? ???? WriteLine ???? ?? ????? ????????? ?? ?? ????????? ???? ?? ??? CTRL + ALT + O ????? ?????? ????? ?????? ????? ????? ???? ???
    Debug.WriteLine("Debug Information-Product Starting ")
    					
  4. ??????? ?? ??? ???????? ????? ????? ??? ?????? ?? ?????? ???? ?? ??? ?????? ???? ?? ????? ????:
    Debug.Indent()
    					
  5. ????? ?? ?? ??????? ????????? ???? ?? ???, ??????????? WriteLine ???? ?? ????? ????:
    Debug.WriteLine("The product name is " & sProdName)
    Debug.WriteLine("The available units on hand are " & iUnitQty)
    Debug.WriteLine("The per unit cost is " & dUnitCost)
    					
  6. ???????? ?? ?? ??? ?? ???? ??? ????????? ???? ?? ??? WriteLine ?? ??? ???? ?? ????? ?? ???? ??? ?? ??????? ???????? ??? ?????? ?? ???, ????? ??? ?? ?????? ????? ??? System.Xml.XmlDocument ??? ????? ????????? ???? ??:
    Dim oxml As New System.Xml.XmlDocument()
    Debug.WriteLine(oxml)
    					
  7. ?????? ????????? ???? ?? ???, ?? ?? ?????? ?? ??? ??? ????? ?? ???? ??? ?? ????????, WriteLine ???? ?? ????? ????? ????????? ??? ?? ?? ??????, ?????? ?? ?????? ????????? ???? ????? ????? ?? "??????: ?????." ?????? ?? ???, ???? ?????? ?? ????? ??? ????????? ???? ?? "??????: ?????? ?? ??? Widget ??" ?????? ??? ?????:
    Debug.WriteLine("The product name is " & sProdName, "Field")
    Debug.WriteLine("The units on hand are " & iUnitQty, "Field")
    Debug.WriteLine("The per unit cost is " & dUnitCost, "Field")
    Debug.WriteLine("Total Cost is" & iUnitQty * dUnitCost, "Calc")
    					
  8. ?????? ????? ????? ???? ?? ????????? ??? ????????? ?? ???? ??? ???? ???? ?????? ?? WriteLineIf ???? ?? ?????? ???? true ?? ?????????? ????? ???? ????? ???????? ???? ?????????? ???? ?? ???? ?? ??? ?? WriteLineIf ???? ??? WriteLineIf ?? ????? ???????? ?? ???? ?? ????? ???? ???? ????? ??? ???? ???? ???????? ?? true ?? ?????????? ???? ???
    Debug.WriteLineIf(iUnitQty > 50, "This message WILL appear")
    Debug.WriteLineIf(iUnitQty < 50, "This message will NOT appear")
    					
  9. ????? ???? ??? ?????? ????? ????????? ???? ?? ???? ???? ?????? ?? Assert ???? ?? ?????? ???? ????????? ???? false ?? ??? ?????????? ???? ??:
    Debug.Assert(dUnitCost > 1, "Message will NOT appear")
    Debug.Assert(dUnitCost < 1, "Message will appear")
    					
  10. ?????? ????? (tr1) ?? ?? ??? ????? ??? TextWriterTraceListener ???????? ????? Output.txt (tr2), ?? ???? ??? ???? ???????? ?? ?????? ???? ?? ??? ???????? ???????? ??????:
    Dim tr1 As New TextWriterTraceListener(System.Console.Out)
    Debug.Listeners.Add(tr1)
            
    Dim tr2 As New _
      TextWriterTraceListener(System.IO.File.CreateText("Output.txt"))
    Debug.Listeners.Add(tr2)
    					
  11. ??????? ?? ???, ?????? ?? ?????? ?? ????? ?? ??????? ?? ??? Unindent ?????? ????? ???? ???? ????? ???? ??? ?? ?????? ?? Unindent ???? ?? ?? ??? ????? ???? ???, ?? ???? ???? ?? ??? ??? ?????? ??? ?? ???? ????
    Debug.Unindent()
    Debug.WriteLine("Debug Information-Product Ending")
    					
  12. ??????? ???????? ?????? ???????? ??? ???? ?????? ???? ?? ?? ????????? ???? ?? ???, ?? ??? ???? ???? ?????? ????? ???? ???:
    Debug.Flush()
    					

????? ???? ?? ????? ????

??? ?? ?? ????? ???? ?? ???????? ?? ??????? ????? ?????? ?? ??? ????? ?? ???? ??? ?? ?????????? ???? ???? ?? ????? ??????? ?????? ?????? ?? ??? ?? ?? ???? ?? ??????? ????, ?????:
  • WriteLine
  • WriteLineIf
  • ??????
  • ???????? ????
  • Assert
  • ?????
??? ?? ????? ?? ???? ??????? ???-??? ?? ?? ??? ?? ????????? ??? ????? ?? ???? ???? ??? ?? ???? ?????? ???????????? ?????????, ????? ?? ????? ???? ?????? ?????? ???? ????? ???? ????????? ?????? ????? ?? ?? ?? ??????? ??? ?????? ?????????? ?? ???? ???????, ?? ?????? ?????? ???????????? project ???? ?? ????? ???? ?????? ????? ???? ??? ??? ???? ???? ???? invocations ?????? ?????? ???????????? ????????? ?? ????? ???? ?????
Trace.WriteLine("Trace Information-Product Starting ")

Trace.Indent()

Trace.WriteLine("The product name is " & sProdName)
Trace.WriteLine("The product name is " & sProdName, "Field")
Trace.WriteLineIf(iUnitQty > 50, "This message WILL appear")
Trace.Assert(dUnitCost > 1, "Message will NOT appear")

Trace.Unindent()
Trace.WriteLine("Trace Information-Product Ending")
Trace.Flush()
Console.ReadLine()
				

?? ??? ?? ???????? ????

  1. ???? ?????? ?? ??????? ???????????? ????????? ???
  2. ?????? Explorer ????? ???????? ???? ??, ?? ????? ?? ????? ????????? ???? ?? ??? CTRL + ALT + L ????? ???????
  3. ConInfo????-????? ????, ?? ???? ??? ???????? ?????
  4. ConInfo ??? ????? ?? ???? ??? ??? ?? ??? ???????????? ???????, ??? ????? ???? ?? ??? ???????????????? ?????
  5. ??? ???????????? ?????-???? ???? ????? ???, ???????????? ???????, ?????? (????) ?? ???? ????????? ????, ?? ?? ???????? ?????
  6. ?????? ????? ????????? ???? ?? ??? CTRL + ALT + O ??????
  7. ??? ?? ????? ?? ??? F5 ????? ?????? ???? ?????? ????? ????? ????? ???? ??, ?? ????? ? ???????? ?????
  8. ????? ????? ???, ENTER ?????? ????????? ???? ????? ?????????? ?????? ??????, ?? ?????? ????? ????????? ???? ?????:
    Debug Information-Product Starting 
        The product name is Widget
        The available units on hand are 100
        The per unit cost is 1.03
        System.Xml.XmlDocument
        Field: The product name is Widget
        Field: The units on hand are 100
        Field: The per unit cost is 1.03
        Calc: Total cost is 103
        This message WILL appear
        ---- DEBUG ASSERTION FAILED ----
    ---- Assert Short Message ----
    Message will appear
    ---- Assert Long Message ----
    
        at Module1.Main()  C:\Documents and Settings\Administrator\My 
        Documents\Visual Studio Projects\conInfo\Module1.vb(29)
    
        The product name is Widget
        The available units on hand are 100
        The per unit cost is 1.03
    Debug Information-Product Ending
    Trace Information-Product Starting 
        The product name is Widget
        Field: The product name is Widget
        This message WILL appear
    Trace Information-Product Ending
    						
  9. ?????? ????? ?? Output.txt ????? ???????? ???? ????? ?????????? ??????:
    (The Output.txt file is located in the same directory as the conInfo 
    executable, conInfo.exe. Normally this is the \bin folder of where the 
    project source has been stored. By default that would be C:\Documents and 
    Settings\User login\My Documents\Visual Studio Projects\conInfo\bin)
        The product name is Widget
        The available units on hand are 100
        The per unit cost is 1.03
    Debug Information-Product Ending
    Trace Information-Product Starting 
        The product name is Widget
        Field: The product name is Widget
        This message WILL appear
    Trace Information-Product Ending
    						

???? ??? ????

Module Module1
    Sub Main()
        Dim sProdName As String = "Widget"
        Dim iUnitQty As Integer = 100
        Dim dUnitCost As Decimal = 1.03

        Debug.WriteLine("Debug Information-Product Starting ")
        Debug.Indent()

        Debug.WriteLine("The product name is " & sProdName)
        Debug.WriteLine("The available units on hand are " & iUnitQty)
        Debug.WriteLine("The per unit cost is " & dUnitCost)

        Dim oxml As New System.Xml.XmlDocument()
        Debug.WriteLine(oxml)

        Debug.WriteLine("The product name is " & sProdName, "Field")
        Debug.WriteLine("The units on hand are " & iUnitQty, "Field")
        Debug.WriteLine("The per unit cost is " & dUnitCost, "Field")
        Debug.WriteLine("Total cost is " & iUnitQty * dUnitCost, "Calc")

        Debug.WriteLineIf(iUnitQty > 50, "This message WILL appear")
        Debug.WriteLineIf(iUnitQty < 50, "This message will NOT appear")

        Debug.Assert(dUnitCost > 1, "Message will NOT appear")
        Debug.Assert(dUnitCost < 1, "Message will appear")

        Dim tr1 As New TextWriterTraceListener(System.Console.Out)
        Debug.Listeners.Add(tr1)

        Dim tr2 As New _
          TextWriterTraceListener(System.IO.File.CreateText("Output.txt"))
        
        Debug.Listeners.Add(tr2)

        Debug.WriteLine("The product name is " & sProdName)
        Debug.WriteLine("The available units on hand are " & iUnitQty)
        Debug.WriteLine("The per unit cost is " & dUnitCost)

        Debug.Unindent()
        Debug.WriteLine("Debug Information-Product Ending")

        Debug.Flush()

        Trace.WriteLine("Trace Information-Product Starting ")

        Trace.Indent()

        Trace.WriteLine("The product name is " & sProdName)
        Trace.WriteLine("The product name is " & sProdName, "Field")
        Trace.WriteLineIf(iUnitQty > 50, "This message WILL appear")
        Trace.Assert(dUnitCost > 1, "Message will NOT appear")

        Trace.Unindent()
        Trace.WriteLine("Trace Information-Product Ending")

        Trace.Flush()

        Console.ReadLine()

    End Sub
End Module
				

?????? ??????

  • ???? ???? ?????? ?????? ???????????? ?????? ??????, ?? ?? ????? ???? ???? ???
  • ?? ????? ?????? ?? ??? ?? TextWriterTraceListener ???? ????? ?? ???, TextWriterTraceListener ?????? ????? ?? ???? ??????? ?? ???????? ?? ?? ?? ????? ?? ???? ???? ?? ?????? ???? TextWriterTraceListener???????? ?? ???? ?? ?????? ?? ??? ????? ?? ??? ??? ???
  • ???? ??????? ?? ????? ??? ?? ?? ?????? ?? ??? ?? ?????? ???????? ??????, ?? ?????? ?? ???????? ???? ???, ?? ?? ??? ?? ????????? ?? ???? ???? ?? ????? ?????? ????? ???? ???
    Dim tr1 As New TextWriterTraceListener(System.Console.Out)
    Debug.Listeners.Add(tr1)
    Dim tr2 As New TextWriterTraceListener(System.Console.Out)
    Trace.Listeners.Add(tr2)
    					

??????

???? ??????? ?? ???, ????? ?????? ??? ????? .??? ????????? ????? ????????? ?? ?????????:
???? ?? ??? ?????
.aspx http://msdn2.microsoft.com/en-us/library/system.diagnostics.trace (vs.71)

???? ???? ????
.aspx http://msdn2.microsoft.com/en-us/library/system.diagnostics.debug (vs.71)


??? ?? ???? ????????? ?????? ?? ???? Instrument?


http://asp.dotnetheaven.com/howto/doc/TraceDemo.aspx
??

http://quickstart.developerfusion.co.uk/quickstart/howto/doc/TraceDemo.aspx

???

???? ID: 313417 - ????? ???????: 07 ?? 2012 - ??????: 3.0
???? ???? ???? ??:
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
??????: 
kbvs2005swept kbvs2005applies kbvs2002sp1sweep kbbug kbdebug kbhowtomaster kbmt KB313417 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:313417

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com