martin2k

Home | Forums | VB6 | Games | Software | Directory | HTML | Wiki | Blog | Contact

I want to create a Notepad program


 

Home

Read and add posts to the Visual Basic 6.0 Forums

Download some of my programs and OCXs

Read the Tips here

The old style forum is still available here

Contact


 

Question

From: Saji john
Date: Thursday 12 July 2001 3:59 AM
Subject: Hi
Question: Hi Mallen

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

Regards

Saji John

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
End Sub

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
Close #1

To open files, use this code:

Open Filename For Input As #1
    Text1.Text = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1

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
Else
    s = LCase(txtFind.Text)
    s2 = LCase(r.Text)
End If

If r.SelStart = 0 And r.SelLength = 0 Then
    i = InStr(r.SelStart + 1, s2, s)
Else
    i = InStr(r.SelStart + 2, s2, s)
End If

If i <> 0 Then
    r.SelStart = i - 1
    r.SelLength = Len(s)
    FindIt = r.SelStart
Else
    If
FindMode = True Then
        MsgBox "<Program name> has finished searching", vbInformation, "Find"
        r.SelStart = 0
        FindIt = -1
    Else
        FindIt = -1
    End If
End If
End Function


blog comments powered by Disqus

Archived Comments

From: abdalla
Date: Saturday, January 15, 2011 at 14:45:17
Comments: thanks for providing now i can create a notepad
 
From: Anoop Kumar
Date: Monday, November 1, 2010 at 00:57:13
Comments: Dear sir,
         Thanks for providing the valuable codes and help.
 
From: Vinay kumar singh
Date: Sunday, July 11, 2010 at 17:08:13
Comments: Hi,
      Thank you sir,actually i was confused to create my note pad at vb 6.0.After see this coading i am create my notepad clearly...
 
From: fooje
Date: Friday, May 7, 2010 at 10:22:49
Comments: thanks you for your help me in vb programming
 
From: me
Date: Sunday, May 2, 2010 at 19:27:22
Comments: Thank you so much for the help. This was just an interest thing for me, and it really helped me for other projects in my coding classes :)
 
From: priya
Date: Sunday, February 28, 2010 at 11:05:12
Comments: i like this vb program bcoz its simple.
 
From: sooraj
Date: Thursday, February 25, 2010 at 05:38:46
Comments: thank you for your valuable codes. I will concern with you later
 
From: sepideh
Date: Thursday, February 11, 2010 at 10:39:23
Comments: thanks for your gides & help.
 
From: kelvin leo
Date: Tuesday, January 12, 2010 at 15:42:23
Comments: ur site is gud cz also i was hvng ze same assignment .kip it up!
 
From: nikhil
Date: Saturday, January 24, 2009 at 05:08:06
Comments: I like this VB Programing
 
From: Grace Catampao
Date: Saturday, January 17, 2009 at 02:36:49
Comments: thank u for providing code and helping me I hope more program that I can learn from this web thank u and God Blessss..
 
From: mmbharat@yahoo.in
Date: Monday, January 12, 2009 at 10:00:26
Comments: I Like A Visual Basic 6.0 Programing Language
 
From: abdulkerim
Date: Thursday, April 24, 2008 at 18:01:35
Comments: thank you i am benefited from your website eventhough i am a new person
i will try to continue all my concerning visual basic 6.0 with you
 
From: sahil juneja
Date: Saturday, September 23, 2006 at 08:37:10
Comments: thanks for providing the code and help..thanks sir
 
From: animal-nt
Date: Wednesday, December 28, 2005 at 10:05:48
Comments: 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.