Monday, July 1, 2013

VB6 Add-Ins - Mengambil String Terpilih (Code Module)

Mengenai cara mengambil string terpilih (selected) dari code module. Adapun kodenya adalah seperti di bawah ini:

Public Function GetSelections() As String 

Dim cd As CodePane
Dim cm As CodeModule

Set cd = VBInstance.ActiveCodePane
Set cm = VBInstance.ActiveCodePane.CodeModule

Dim StartLine As Long
Dim StartColoum As Long
Dim EndLine As Long
Dim EndColoum As Long

Dim sKeyword As String

cd.GetSelection StartLine, StartColoum, EndLine, EndColoum
sKeyword = cm.Lines(StartLine, EndLine)
GetSelections = Mid$(sKeyword, StartColoum, EndColoum - StartColoum)

End Function