目的:单击第六列的格子,得到同一行中第5列格子里存的内容
下面是我的程序。
Private Sub FlexZl_Click()
    Dim temprow As Long
       If FlexZl.Col = 6 Then
        Debug.Print FlexZl.Row
        temprow = FlexZl.Row
        If FlexZl.Row <> gridrow Then
           If gridrow <> 0 Then
              If gridrow < FlexZl.Rows Then
                  FlexZl.Row = gridrow
              Else
                  FlexZl.Row = 0
              End If
              FlexZl.CellBackColor = &HE0E0E0
           End If
           FlexZl.Row = temprow
           FlexZl.CellBackColor = vbRed
           gridrow = temprow
           FlexZl.Col = 5
           If Dir(FlexZl.Text) <> "" Then
            MsgBox "hah"
           ElseIf Dir(FlexZl.Text) = "" Then
            MsgBox "无效"
           End If           MediaZl.Enabled = True
           MediaZl.FileName = FlexZl.Text        Else
           If FlexZl.CellBackColor = vbRed Then
              FlexZl.CellBackColor = &HE0E0E0
              MediaZl.FileName = ""
              MediaZl.Enabled = False
           Else
              FlexZl.CellBackColor = vbRed
              MediaZl.ShowPositionControls = False
              MediaZl.Enabled = True
              FlexZl.Col = 5
              MediaZl.FileName = FlexZl.Text
           End If
        End If
    End If
End Sub

解决方案 »

  1.   

    你写这么长段代码是做什么,看得很辛苦,却不知道你要写什么点的时候,点第6格,取第5格的内容with me.msflexgrid
       if .col=5 then
          .col=4
          msgbox .text
      end if
    end with
      

  2.   

    点第六格,它的背景变红,我点的第二行的第六列,红的却是第一行的第六列第五列里存的一个录音路径,debug的时候这个路径是对的,用dir却是无效的MediaZl.FileName = FlexZl.Text
      

  3.   

    点击第六列,被点击的格子背景变红,得出同一行第五列里存的内容,里面放的是一个录音文件的路径
    例如C:\Documents and Settings\Administrator\桌面\调度总机3.16\rec\20050316202456.wav
    然后mediaplayer.filename=这个路径
    现在debug.print flex.text能得出这个路径
    但mediaplayer.filename=flex.text就是空的