积极答复者
vb.net select case

问题
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error GoTo 0
On Error Resume Next
If System.IO.Directory.Exists(s) = False Then
Call path()
Else
WebBrowser1.Navigate(s)
End If
Exit Sub
Resume Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
On Error GoTo 0
On Error Resume Next
If System.IO.Directory.Exists(i) = False Then
Call path()
Else
WebBrowser1.Navigate(i)
End If
Exit Sub
Private Sub path()
Select Case
Case 1
MsgBox("The specified path does not exist." + vbCrLf + s, MsgBoxStyle.Critical, "Error")
Case 2
MsgBox("The specified path does not exist." + vbCrLf + i, MsgBoxStyle.Critical, "Error")
End Select
End Sub
s=c:\1
i=c:\2
要怎样写才可以让各自的按键钮选择各自的case?
如button1应该选择case1,button2应该选择case2….
答案
-
Private Sub path( index as int32) Select Case index Case 1 MsgBox("The specified path does not exist." + vbCrLf + s, MsgBoxStyle.Critical, "Error") Case 2 MsgBox("The specified path does not exist." + vbCrLf + i, MsgBoxStyle.Critical, "Error") End Select End Sub 在button1调用的时候 path( 1)
成为 Microsoft V Dash了。。。 欢迎各位前辈同事在OCS加我- 已标记为答案 ckjason 2010年8月11日 8:03
全部回复
-
Private Sub path( index as int32) Select Case index Case 1 MsgBox("The specified path does not exist." + vbCrLf + s, MsgBoxStyle.Critical, "Error") Case 2 MsgBox("The specified path does not exist." + vbCrLf + i, MsgBoxStyle.Critical, "Error") End Select End Sub 在button1调用的时候 path( 1)
成为 Microsoft V Dash了。。。 欢迎各位前辈同事在OCS加我- 已标记为答案 ckjason 2010年8月11日 8:03
-
你好
或者你可以改變PATH() 這個功能
Private Sub path(byval MsgStyleNo as Integer)
Select Case MsgStyleNo
Case 1
MsgBox("The specified path does not exist." + vbCrLf + s, MsgBoxStyle.Critical, "Error")
Case 2
MsgBox("The specified path does not exist." + vbCrLf + i, MsgBoxStyle.Critical, "Error")
End Select
End Sub
之後再 Call path() 時
分別把 Button1 的 Call Path() 改成 Path(1)
Button2 的 Call Path() 改成 Path(2)Please forgive me if I mis-understood your questions
你可以看看你另一個POST 我已經加了 DataGridView 的 Sample Code 了
http://social.microsoft.com/Forums/zh-CN/vbasiczhchs/thread/ae3fbcd7-84db-4807-a294-0deeab7e3f7a
Chi