讓我們的程序寫得更加平易近人
程序健壯性最基本要求就是程序錯誤的處理與捕捉
網頁設計中
在ASP
Dim myOutputString As String =My name is
Dim myInputString As String =Alex
myOutputString = myOutputString & myInputString
ResponseWrite(myoutputString)
現在
(
Append和其他語言的Append一樣
http://wwwCodeHighlighter com/ >Dim sb as StringBuilder = New StringBuilder()
sbappend( )
For i =To RowCount
sbAppend( )
For k =To ColCount
sbAppend( )
sbAppend( dt Rows(i) Item(k DataRowVersion Current) toString())
sbAppend( )
Next
sbAppend( )
Next
sbAppend( )
Dim strOutput as String = sbToString()
lblCompanyText = strOutput
在以上的程序中
http://wwwCodeHighlighter com/ >Sub Page_Load(Source As Object E As EventArgs)
Dim sb As SystemText StringBuilder
Dim varother As Integer
varother=
sb =new SystemText StringBuilder()
sbappend( 可以Append其他類型 )
sbappend(varother)
Responsewrite(sb toString())
End Sub
(
我們還可以使用其他方法
Insert方法
Remove方法
Replace方法
在使用ASP編程的時候
(
Dim myConnection As SqlConnection =
new SqlConnection(ConfigurationSettingsAppSettings( DSN_pubs ))
Dim myCommand As SqlCommand =
new SqlCommand(Select pub_id pub_name From publishers myConnection)
Dim myDataReader As SqlDataReader
Try
myConnectionOpen()
myDataReader = myCommandExecuteReader(CommandBehavior CloseConnection)
DropDownListDataSource = myDataReader
DropDownListDataBind()
Catch myException As Exception
ResponseWrite( An error has occurred: & myException ToString())
Finally
If Not myDataReader Is Nothing Then
\\\關閉DataReader
myDataReaderClose()
End If
End Try
在以上的舉例中
(
http://wwwCodeHighlighter com/ >Dim myConnection As SqlConnection =
new SqlConnection(ConfigurationSettingsAppSettings( DSN_pubs ))
Dim myCommand As SqlCommand =
new SqlCommand(Select pub_id pub_name From publishers myConnection)
Try
myConnectionOpen()
DropDownListDataSource = myCommand ExecuteReader()
DropDownListDataBind()
Catch myException As Exception
ResponseWrite( An error has occurred: & myException ToString())
Finally
If Not myConnection Is Nothing AndAlso
((myConnectionState And ConnectionState Open) = ConnectionState Open) Then
myConnectionClose()
End If
End Try
在以上的舉例中
From:http://tw.wingwit.com/Article/program/net/201311/15637.html