2014-01-21 71 views
0

這是我的工作代碼 - 每次我點擊一個標記時,它都會顯示其持有的相應表單。 代碼表單不會做我想要的他

For Each elem In aList 
       If item.ToolTipText = elem.MarkerName Then 

        Dim camera = markerDtable.Select("MarkerName =" & " '" & elem.MarkerName & "'")(0)("cameraID") 
        Dim host = markerDtable.Select("MarkerName =" & " '" & elem.MarkerName & "'")(0)("HostAddress")  

        With f 
         .Show() 
         .AxXHDec1.Camera = camera 
         .AxXHDec1.Host = host 
         .AxXHDec1.Play = 1 
         Dim p As New Point 
         p = item.LocalPosition + New Point(45, 68) 
         .Location = p 
         .Text = elem.MarkerName 
        End With 
        Exit Sub 
       End If 
      Next 

這就是我基於這個第二個,同樣的程序雖然不是一個標誌,而是一個按鈕的代碼。 代碼B

For Each btn In bList 
     Dim fcb As New Fcamera4Building 
     Dim word() As String = btn.Name.Split("m"c) 
     With fcb 
      .Show() 
      .AxXHDec1.Camera = word(1) 
      .AxXHDec1.Host = 'get corresponding HostAddress depending on what buttonName' 
      .AxXHDec1.Play = 1 
      Dim p As New Point 
      p = btn.Location + New Point(70, 160) 
      .Location = p 
     End With 
     Exit Sub 
    Next 

,我認爲我做了我應該做的,但是,該代碼B顯示相同的形式。當我點擊CAM1按鈕時,我有兩個按鈕(從數據庫加載的開始),給我一個相機。但是當我點擊CAM3顯示相同的形式,並且相同的位置。

我在想什麼/做錯了什麼?讓我知道你是否需要一些東西。
UPDATE:似乎word()沒有註冊3.無論我點擊,它的值是1

回答

0

如果您的相機名稱是「CAM1」,「CAM2」,它可能是值得改變:

Dim word() As String = btn.Name.Split("m"c) 

到:

Dim word() As String = btn.Name.ToLower.Split("m"c) 
0
Private Sub nBtn_Click(ByVal sender As Button, ByVal e As System.EventArgs) 
    For Each btn In b2List 
     If sender.Text = btn Then ' This will check the same name so it will distinguish which form will be shown. 
      ' do code