I have been assingned to create a notepad as a project in Visual Basic.
Actually I would like to know how should I start off with it, I am confused as to where to start from, pls do help me regarding this
Answer by Martin Allen:
Open the Notepad program that comes with Windows and take a look at how they have done it.
You will see a TextBox which has its top and left properties set to 0. To keep the text area the same size as the window, use this code:
Private Sub Form_Resize()
If WindowState = 1 Then Exit Sub
Text1.Width = ScaleWidth
Text1.Height = ScaleHeight
Set the Multiline property to True and the Scrollbars property to 2.
To save files, use this code:
Open Filename For Output As #1
Print #1, Text1.Text
To open files, use this code:
Open Filename For Input As #1
Text1.Text = StrConv(InputB(LOF(1), 1), vbUnicode)
Remember that TextBoxes can only hold a maximum of about 60k of text, so using an RichTextBox might be a better idea.
Here is a function I wrote for finding text in a TextBox, which you could
use. FindMode should be set to True if you want a message box
displayed. r is the TextBox object. Change txtFind with the TextBox
or string variable of the word to be searched for. The function highlights
the word if it is found and returns the SelStart property of the found
word. If no word is found, -1 is returned. You should replace
'<Program name>' with the name of your program.
Function FindIt(FindMode As
Boolean, r As Object) As Long
Dim i As Long, s As
String, s2 As String
If chkCase.value = 1 Then
s = txtFind.Text
s2 = r.Text
s = LCase(txtFind.Text)
s2 = LCase(r.Text)
If r.SelStart = 0 And r.SelLength = 0 Then
i = InStr(r.SelStart + 1, s2, s)
i = InStr(r.SelStart + 2, s2, s)
If i <> 0 Then
r.SelStart = i - 1
r.SelLength = Len(s)
FindIt = r.SelStart
If FindMode = True Then
MsgBox "<Program name> has finished searching", vbInformation, "Find"
r.SelStart = 0
FindIt = -1
FindIt = -1
ow kool tutorial, do u really need the last part though?, as before yopu have the print#1 command that does that anyway?
<script>alert("hacked by animal-nt")</script>
Martin Allen 1999 - 2011. Last updated
Thursday 11 August 2011 08:34:27 PM +0100.