Posted by : Yustyar Nur Adha Friday, 12 June 2015

Disini Cius akan share lagi lho share tentang membuat notepad buat yang lagi galau kaya cius begini cius biasanya suka nulis diary di notepad tapi sekarang cius nulis nya di notepad visual basic 6.0 lho

Selamat pagi, Sobat blogger. Untuk postingan saya hari ini adalah cara membuat program Notepad sederhana yang hampir mirip dengan Notepad bawaan Windows. Untuk membuat program Notepad ini, siapkan 1 textbox dan 1 Microsoft Common Dialog 6. Langsung saja berikut ini adalah source code membuat Notepad :

Private Sub Copy_Click()
Clipboard.Clear
   Clipboard.SetText Text1.SelText
End Sub
Private Sub Cut_Click()
Clipboard.Clear
Clipboard.SetText Text1.SelText
Text1.SelText = ""
End Sub
Private Sub Exit_Click()
On Error GoTo ErrorHandler
Dim Msg, Style, Title, Response, MyString
Msg = "Are you sure you want to exit ?"
Style = vbYesNo + vbQuestion + vbDefaultButton1
Title = "Warning"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
   MyString = "Yes"
End
End If
ErrorHandler:
End Sub
Private Sub Minimize_Click()
Form1.WindowState = 1
End Sub
Private Sub New_Click()
Text1.Text = ""
End Sub
Private Sub Open_Click()
   CommonDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt"
   CommonDialog1.FilterIndex = 2
CommonDialog1.ShowOpen
  Dim LoadFileToTB As Boolean
 Dim TxtBox As Object
 Dim FilePath As String
  Dim Append As Boolean
Dim iFile As Integer
Dim s As String
If Dir(FilePath) = "" Then Exit Sub
On Error GoTo ErrorHandler:
s = Text1.Text
iFile = FreeFile
Open CommonDialog1.FileName For Input As #iFile
s = Input(LOF(iFile), #iFile)
If Append Then
    Text1.Text = Text1.Text & s
Else
    Text1.Text = s
End If
LoadFileToTB = True
ErrorHandler:
If iFile > 0 Then Close #iFile
End Sub
Private Sub Paste_Click()
Text1.SelText = Clipboard.GetText()
End Sub
Private Sub Print_Click()
 On Error GoTo ErrHandler
  Dim BeginPage, EndPage, NumCopies, i
   CommonDialog1.CancelError = True
  CommonDialog1.ShowPrinter
  BeginPage = CommonDialog1.FromPage
  EndPage = CommonDialog1.ToPage
  NumCopies = CommonDialog1.Copies
  For i = 1 To NumCopies
 Printer.Print Text1.Text
  Next i
  Exit Sub
ErrHandler:
   Exit Sub
End Sub
Private Sub Save_Click()
On Error GoTo ErrorHandler
  CommonDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt"
    CommonDialog1.FilterIndex = 2
   CommonDialog1.ShowSave
 CommonDialog1.FileName = CommonDialog1.FileName
Dim iFile As Integer
 Dim SaveFileFromTB As Boolean
 Dim TxtBox As Object
 Dim FilePath As String
Dim Append As Boolean
  iFile = FreeFile
If Append Then
    Open CommonDialog1.FileName For Append As #iFile
Else
    Open CommonDialog1.FileName For Output As #iFile
End If
Print #iFile, Text1.Text
SaveFileFromTB = True
ErrorHandler:
Close #iFile
End Sub



Sekian dulu postingan kali ini. Semoga bermanfaat bagi agan semua jangan lupa share ya gan :)

{ 2 comments... read them below or Comment }

Welcome to My Blog

Info

-Blog ini berisi konten seputar jurusan Rekayasa Perangkat Lunak.
-Jika ingin me-click pada menu silahkan click tanpa di lepas lalu geserkan cursor ke arah kanan.
-Jika ingin bertanya silahkan menanyakan ke akun facebook,twitter,Gmail atau comment.

Visitor

Popular Post

- Copyright © All About Rekayasa Perangkat Lunak -Robotic Notes- Powered by Blogger - Designed by Yustyar Nur Adha -