|
-
Jun 3rd, 2000, 10:53 PM
#1
Thread Starter
Addicted Member
Ever played zelda??
When someone talks to you the more importain
words are in red, places in green. and such.
I want to do this to the game im making but
I believe that impossable with the label COntroll.
IS there one I could do that with, and or
could I do that with the label controll?
-
Jun 3rd, 2000, 11:08 PM
#2
You could use a RichTextBox and set the BackColour to whatever you want and have the Locked property set to True so it will act as a label.
Then you can put this code in the General Section
Code:
Option Explicit
Private Sub HighlightText(sKeyword As String, iColour As Long)
Dim nStart As Integer, sPrevChar As String, sNextChar As String
nStart = InStr(1, LCase(RichTextBox1.Text), sKeyword)
Do While nStart <> 0
If nStart > 1 Then
sPrevChar = Mid$(RichTextBox1.Text, nStart - 1, 1)
Else
sPrevChar = " "
End If
If Len(RichTextBox1.Text) >= nStart + Len(sKeyword) Then
sNextChar = Mid$(RichTextBox1.Text, nStart + Len(sKeyword), 1)
Else
sNextChar = " "
End If
If (sPrevChar = Chr(32) Or sPrevChar = Chr(13) Or _
sPrevChar = Chr(10) Or sPrevChar = Chr(9)) And _
(sNextChar = Chr(32) Or sNextChar = Chr(13) Or _
sNextChar = Chr(10) Or sNextChar = Chr(9)) Then
With RichTextBox1
.SelStart = nStart - 1
.SelLength = Len(sKeyword)
.SelColor = iColour
.SelText = UCase(sKeyword)
.SelStart = Len(RichTextBox1.Text)
.SelColor = vbBlack
End With
End If
nStart = InStr(nStart + Len(sKeyword), LCase(RichTextBox1.Text), sKeyword)
Loop
End Sub
Now put this code in a CommandButton.
Code:
Private Sub Command1_Click()
With RichTextBox1
.SelStart = 0
.SelLength = Len(.Text)
.SelColor = vbBlack
.SelStart = Len(.Text)
End With
' Add more custom words here
HighlightText "bowser", vbBlue
HighlightText "danger", vbRed
HighlightText "palace", vbMagenta
HighlightText "mario", vbGreen
End Sub
when you type in the words bowser, danger, palace and mario, they will all turn into different colours when you click the Commandbutton.
-
Jun 4th, 2000, 02:46 AM
#3
transcendental analytic
No haven't played zelda, but you can change the forecolor of a label. Also if you wan't you can draw diectly on the form, change forms forecolor and use print
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 4th, 2000, 03:16 AM
#4
But you might have a hard time trying to get the text whewre you want it on the form.
-
Jun 4th, 2000, 05:51 AM
#5
transcendental analytic
No Meg, the form have a currentx and currenty property which is the next position to write.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|