Jori13
Gebruiker
- Lid geworden
- 18 jan 2010
- Berichten
- 159
Hallo Helpmij forum mensen, 
Ik heb een paar kleine vraagjes waar jullie mij misschien bij kunnen helpen.Ik ben bezig om in VB een VBScript editor te maken, vanzelf sprekend hoort daar een regel en karakter teller bij maar ook syntax highliting. Nou heb ik op internet voorbeelden gevonden voor beide. Het probleem is echter dat ze beide niet werken. Mijn vraag; weten jullie een site met wel werkende code (of een waar wordt uigelegd hoe je zelf die code kan schrijven) of weten jullie waarom deze niet werkt en wat ik er aan kan doen?
Alvast heel erg bedankt voor jullie antwoord(en)!
De links en codes:
Syntax-highliting:
http://support.microsoft.com/kb/154884
Regel en karakter teller:
http://www.vbforums.com/showthread.php?p=2161803#post2161803

Ik heb een paar kleine vraagjes waar jullie mij misschien bij kunnen helpen.Ik ben bezig om in VB een VBScript editor te maken, vanzelf sprekend hoort daar een regel en karakter teller bij maar ook syntax highliting. Nou heb ik op internet voorbeelden gevonden voor beide. Het probleem is echter dat ze beide niet werken. Mijn vraag; weten jullie een site met wel werkende code (of een waar wordt uigelegd hoe je zelf die code kan schrijven) of weten jullie waarom deze niet werkt en wat ik er aan kan doen?
Alvast heel erg bedankt voor jullie antwoord(en)!
De links en codes:
Syntax-highliting:
http://support.microsoft.com/kb/154884
Code:
Option Explicit
Private Sub Command1_Click()
HighlightWords RichTextBox1, "text", vbRed
End Sub
Private Function HighlightWords(rtb As RichTextBox, _
sFindString As String, _
lColor As Long) _
As Integer
Dim lFoundPos As Long 'Position of first character
'of match
Dim lFindLength As Long 'Length of string to find
Dim lOriginalSelStart As Long
Dim lOriginalSelLength As Long
Dim iMatchCount As Integer 'Number of matches
'Save the insertion points current location and length
lOriginalSelStart = rtb.SelStart
lOriginalSelLength = rtb.SelLength
'Cache the length of the string to find
lFindLength = Len(sFindString)
'Attempt to find the first match
lFoundPos = rtb.Find(sFindString, 0, , rtfNoHighlight)
While lFoundPos > 0
iMatchCount = iMatchCount + 1
rtb.SelStart = lFoundPos
'The SelLength property is set to 0 as
'soon as you change SelStart
rtb.SelLength = lFindLength
rtb.SelColor = lColor
'Attempt to find the next match
lFoundPos = rtb.Find(sFindString, _
lFoundPos + lFindLength, , rtfNoHighlight)
Wend
'Restore the insertion point to its original
'location and length
rtb.SelStart = lOriginalSelStart
rtb.SelLength = lOriginalSelLength
'Return the number of matches
HighlightWords = iMatchCount
End Function
Regel en karakter teller:
http://www.vbforums.com/showthread.php?p=2161803#post2161803
Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any _
) As Long
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINEINDEX = &HBB
Private Sub GetCursorPos(RTB As RichTextBox, iLine As Integer, iPos As Integer)
Dim lCount As Long
Dim i As Long
Dim LN As Long
lCount = SendMessage(RTB.hwnd, EM_GETLINECOUNT, 0&, 0&)
LN = SendMessage(RTB.hwnd, EM_LINEINDEX, -1&, 0&)
For i = 1 To lCount
If LN = SendMessage(RTB.hwnd, EM_LINEINDEX, i - 1, 0) Then Exit For
Next i
iLine = i
iPos = RTB.SelStart - LN + 1
End Sub
Laatst bewerkt: