I need the forms in my project to remember where they were on last load.
Secondly,
I also need (this one's a bit trickier) to be able to have certain text in a RichTextBox displayed certain colours.
E.G. Like in html editors that set different tags <tag> to different colours
'Using the registery by using SaveSetting and GetSetting
Option Explicit
'
'assuming you have only one form this will work
'if you want to delete the save settings click on command2
Private Sub Command2_Click()
'this will delete it from the register if you are finished
'with playing with it
DeleteSetting "project1", "Left"
DeleteSetting "project1", "Top"
End Sub
Private Sub Form_Load()
'this will load it into the register
Me.Top = GetSetting("project1", "Top", "Value", 0)
Me.Left = GetSetting("project1", "Left", "Value", 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'this will save it into the register when you quit
Dim x, y
x = Me.Top
y = Me.Left
SaveSetting "project1", "Top", "Value", x
SaveSetting "project1", "Left", "Value", y
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
'using this I color all words Reference blue.
Private Sub MakeColored()
Dim x
For x = 1 To Len(RichTextBox1.Text)
If Mid(RichTextBox1.Text, x, Len("Reference")) = "Reference" Then
RichTextBox1.SelStart = x - 1
RichTextBox1.SelLength = Len("Reference")
RichTextBox1.SelColor = vbBlue
RichTextBox1.SelLength = 0
RichTextBox1.SelColor = vbBlack
x = (x - 1) + Len("Reference")
Else
RichTextBox1.SelColor = vbBlack
End If
Next x
RichTextBox1.SelStart = Len(RichTextBox1.Text)
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
1) You could store the left and top properties of a form in the registry. I use this code to accomplish this. It works for more than 1 form too :
Code:
Private Sub Form_Load()
Me.Move GetSettingString(HKEY_LOCAL_MACHINE, "Software\MyCompany\MyApp\User Preferences\Window Pos", Me.Name & "Left"), GetSettingString(HKEY_LOCAL_MACHINE, "Software\MyCompany\MyApp\User Preferences\Window Pos", Me.Name & "Top")
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If Me.WindowState <> vbMinimized Then
' Save form window position LEFT
SaveSettingString HKEY_LOCAL_MACHINE, "Software\MyCompany\MyApp\User Preferences\Window Pos", Me.Name & "Left", Me.Left
' TOP
SaveSettingString HKEY_LOCAL_MACHINE, "Software\MyCompany\MyApp\User Preferences\Window Pos", Me.Name & "Top", Me.Top
End If
End Sub
You'll need to include the attached registry.bas for this to work!
2) There are loads of threads around asking the same sort of thing. Try this or perform a search for "Colour Coding"