Oliver Scheiber
2007-08-21 10:44:08 UTC
Hi,
i have developed an AddIn for the VB-IDE using visual basic 6.0.
Now I would like to insert a comment, but only even if the cursor is
in a procedure.
I tried this code but it doesn't works fine, it always comes MsgBox
"Cursor not in procedure!":
Public Function InsertComment()
Dim MyCodePane As CodePane
Dim MyCodeMod As CodeModule
Dim iCurrentLine As Long, b As Long, c As Long, d As Long
Set MyCodePane = VBInstance.ActiveCodePane
Set MyCodeMod = MyCodePane.CodeModule
MyCodePane.GetSelection iCurrentLine, b, c, d
If iCurrentLine <> b Or c <> d Then
MsgBox "Cursor not in procedure!"
Else
MsgBox "Jeah, cursor in procedure!"
MyCodeMod.InsertLines iCurrentLine, "'This is a comment"
End If
End Function
Any suggestion?
Regards Oliver
i have developed an AddIn for the VB-IDE using visual basic 6.0.
Now I would like to insert a comment, but only even if the cursor is
in a procedure.
I tried this code but it doesn't works fine, it always comes MsgBox
"Cursor not in procedure!":
Public Function InsertComment()
Dim MyCodePane As CodePane
Dim MyCodeMod As CodeModule
Dim iCurrentLine As Long, b As Long, c As Long, d As Long
Set MyCodePane = VBInstance.ActiveCodePane
Set MyCodeMod = MyCodePane.CodeModule
MyCodePane.GetSelection iCurrentLine, b, c, d
If iCurrentLine <> b Or c <> d Then
MsgBox "Cursor not in procedure!"
Else
MsgBox "Jeah, cursor in procedure!"
MyCodeMod.InsertLines iCurrentLine, "'This is a comment"
End If
End Function
Any suggestion?
Regards Oliver