• Tidak ada hasil yang ditemukan

Hengky Alexander, dan Winpec. 2012. Membangun Aplikasi Sistem Informasi Manufaktur dengan Visual Basic 2010. Jakarta: PT Elex Media Komputindo. Kadir, Abdul. 2008. Mudah Menjadi Programmer VISUAL BASIC. Yogyakarta:

YESCOM.

Nikodemus. 2012. Aplikasi Database untuk Tugas Akhir Menggunakan Visual Basic 2010. Yogyakarta: Andi.

Sadeli, M. 2012. Aplikasi Penjualan dengan Visual Basic 2010 untuk Profesional. Palembang: Maxikom.

Private Sub updateNumberLabel() Dim i As Integer = 0

Dim pos As Point = New Point(i, 0) Dim firstIndex As Integer =

RtbEditor.GetCharIndexFromPosition(pos) Dim firstLine As Integer =

RtbEditor.GetLineFromCharIndex(firstIndex) pos.X = ClientRectangle.Width

pos.Y = ClientRectangle.Height Dim lastIndex As Integer =

RtbEditor.GetCharIndexFromPosition(pos) Dim lastLine As Integer =

RtbEditor.GetLineFromCharIndex(lastIndex)

pos = RtbEditor.GetPositionFromCharIndex(lastIndex)l LblNomor.Text = " "

For i = firstLine To lastLine + 1 LblNomor.Text += i + 1 & vbLf Next

End Sub

Private Sub RtbEditor_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RtbEditor.KeyDown

updateNumberLabel() End Sub

Private Sub rtb_VScroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RtbEditor.VScroll Dim d As Integer =

(RtbEditor.GetPositionFromCharIndex(0).Y Mod (RtbEditor.Font.Height + 1))

updateNumberLabel() End Sub

Private Sub RtbEditor_FontChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RtbEditor.FontChanged

updateNumberLabel()

rtb_VScroll(Nothing, Nothing) End Sub

Private Sub RtbEditor_Resize_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RtbEditor.Resize

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)

WBrHasil.DocumentText = RtbEditor.Text End Sub

Private Sub frmIsi_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

RtbEditor.Focus() End Sub

Private Sub RtbEditor_TextChanged(ByVal sender As

System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RtbEditor.KeyDown

If e.KeyCode = Keys.Enter Then End If

End Sub End Class

Dim index As Integer = 0 Dim kata As String = ""

Private Sub ButtonCari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCari.Click

cari() End Sub Sub cari()

If Not (kata = txtKataCari.Text) Then Kembali(kata, FrmUtama.fIs.RtbEditor) findTextAndHighlight(txtKataCari.Text, FrmUtama.fIs.RtbEditor) kata = txtKataCari.Text Else findTextAndHighlight(txtKataCari.Text, FrmUtama.fIs.RtbEditor) End If End Sub

Sub findTextAndHighlight(ByVal searchtext As String, ByVal rtb As RichTextBox)

Dim textEnd As Integer = rtb.TextLength

Dim fnt As Font = New Font(rtb.Font, FontStyle.Bold) Dim lastIndex As Integer =

rtb.Text.LastIndexOf(searchtext) If (index < lastIndex) Then If (index > 0) Then

rtb.Find(searchtext, index - 1, textEnd, RichTextBoxFinds.WholeWord) rtb.SelectionFont = fnt rtb.SelectionLength = searchtext.Length rtb.SelectionColor = Color.Black rtb.SelectionBackColor = Color.White End If

rtb.Find(searchtext, index, textEnd, RichTextBoxFinds.WholeWord)

rtb.SelectionFont = fnt

rtb.SelectionLength = searchtext.Length rtb.SelectionColor = Color.Red

rtb.SelectionBackColor = Color.Cyan

FrmUtama.fIs.RtbEditor) index = 0 End If

End Sub

Sub findAll(ByVal searchtext As String, ByVal rtb As RichTextBox)

Dim textEnd As Integer = rtb.TextLength index = 0

Dim fnt As Font = New Font(rtb.Font, FontStyle.Bold) Dim lastIndex As Integer =

rtb.Text.LastIndexOf(searchtext) While (index < lastIndex)

rtb.Find(searchtext, index, textEnd, RichTextBoxFinds.WholeWord)

rtb.SelectionFont = fnt

rtb.SelectionLength = searchtext.Length rtb.SelectionColor = Color.Red

rtb.SelectionBackColor = Color.Cyan

index = rtb.Text.IndexOf(searchtext, index) + 1 End While

End Sub

Sub Kembali(ByVal searchtext As String, ByVal rtb As RichTextBox)

Dim textEnd As Integer = rtb.TextLength index = 0

Dim fnt As Font = New Font(rtb.Font, FontStyle.Regular)

Dim lastIndex As Integer = rtb.Text.LastIndexOf(searchtext) While (index < lastIndex)

rtb.Find(searchtext, index, textEnd, RichTextBoxFinds.WholeWord)

rtb.SelectionFont = fnt

rtb.SelectionLength = searchtext.Length rtb.SelectionColor = Color.Black

rtb.SelectionBackColor = Color.White

index = rtb.Text.IndexOf(searchtext, index) + 1 End While

index = 0 End Sub

FrmUtama.fIs.RtbEditor.SelectedText Txtcari.Text = txtKataCari.Text End Sub

Private Sub btnFindA_Click(ByVal sender As

System.Object, ByVal e As System.EventArgs) Handles btnFindA.Click

findAll(txtKataCari.Text, FrmUtama.fIs.RtbEditor) End Sub

Private Sub FrmCari_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing Kembali(txtKataCari.Text, FrmUtama.fIs.RtbEditor) Kembali(TxtGanti.Text, FrmUtama.fIs.RtbEditor) End Sub

Private Sub ButtonBatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonBatal.Click

Me.Close() End Sub

Private Sub ButtonFinds_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

cari() End Sub

Private Sub ButtonReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonReplace.Click

If ButtonReplace.Text = "Find" Then cari() index = index - 1 ButtonReplace.Text = "Replace" Else FrmUtama.fIs.RtbEditor.SelectedText = TxtGanti.Text ButtonReplace.Text = "Find" index = index - 1 End If End Sub

ButtonReplaceA.Click

ReplaceAll(Txtcari.Text, FrmUtama.fIs.RtbEditor) End Sub

Sub ReplaceAll(ByVal searchtext As String, ByVal rtb As RichTextBox)

Dim textEnd As Integer = rtb.TextLength index = 0

Dim fnt As Font = New Font(rtb.Font, FontStyle.Bold) Dim lastIndex As Integer =

rtb.Text.LastIndexOf(searchtext) While (lastIndex > 0)

rtb.Find(searchtext, index, textEnd, RichTextBoxFinds.WholeWord) rtb.SelectionFont = fnt rtb.SelectionLength = searchtext.Length rtb.SelectionColor = Color.Red rtb.SelectionBackColor = Color.Cyan rtb.SelectedText = TxtGanti.Text lastIndex = rtb.Text.LastIndexOf(searchtext) End While End Sub

Private Sub ButtonBatalR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonBatalR.Click

Me.Close() End Sub

Dim Tab As TabPage Public fIs As frmIsi

Sub menuAksi(ByVal X As Boolean)

SaveAsToolStripMenuItem.Enabled = X SaveToolStripMenuItem.Enabled = X PrintPreviewToolStripMenuItem.Enabled = X PrintToolStripMenuItem.Enabled = X TutupTabToolStripMenuItem.Enabled = X HasliToolStripMenuItem.Enabled = X FindToolStripMenuItem.Enabled = X End Sub

Private Sub AddTab(Optional ByVal file As String = Nothing)

Dim lokasiFile As String = "" Dim NewTab As New TabPage Dim frm As New frmIsi frm.Dock = DockStyle.Fill frm.TopLevel = False NewTab.Tag = frm NewTab.BackColor = Color.DeepSkyBlue frm.Parent = NewTab frm.Show()

Dim TabText As String = "Untitled" Dim RTBText As String = Nothing If Not IsNothing(file) Then

If My.Computer.FileSystem.FileExists(file) Then lokasiFile =

My.Computer.FileSystem.GetFileInfo(file).FullName TabText =

My.Computer.FileSystem.GetFileInfo(file).Name Dim reader As New

System.IO.StreamReader(file)

RTBText = reader.ReadToEnd reader.Close()

Else

MsgBox("Sorry that file doesn't exist") End If

End If

NewTab.Text = TabText

NewTab.ToolTipText = lokasiFile frm.RtbEditor.Text = RTBText

fIs = frm btnTutuptab.Visible = True btnTutuptab.Enabled = True btnHasil.Enabled = True BtnSplit.Enabled = True btnText.Enabled = True End Sub

Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

NewToolStripMenuItem.Click AddTab()

End Sub

Private Sub FrmUtama_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing While (TabControl1.TabCount > 0) tutuptab() End While End Sub

Private Sub FrmUtama_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

AddTab() Timer2.Enabled = True btnHasil.Enabled = False BtnSplit.Enabled = False btnText.Enabled = False menuAksi(True) End Sub

Private Sub BtnSplit_Click(ByVal sender As

System.Object, ByVal e As System.EventArgs) Handles BtnSplit.Click

fIs.SpCIsi.Panel1Collapsed = False fIs.SpCIsi.Panel2Collapsed = False End Sub

Private Sub btnText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnText.Click

fIs.SpCIsi.Panel1Collapsed = False fIs.SpCIsi.Panel2Collapsed = True End Sub

fIs.SpCIsi.Panel2Collapsed = False fIs.SpCIsi.Panel1Collapsed = True tampil()

End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

With fIs If .RtbEditor.CanUndo Then UndoToolStripMenuItem.Enabled = True Else UndoToolStripMenuItem.Enabled = False End If If .RtbEditor.CanRedo Then RedoToolStripMenuItem.Enabled = True Else RedoToolStripMenuItem.Enabled = False End If If .RtbEditor.SelectedText.Length > 0 Then CopyToolStripMenuItem.Enabled = True CutToolStripMenuItem.Enabled = True Else CopyToolStripMenuItem.Enabled = False CutToolStripMenuItem.Enabled = False End If If My.Computer.Clipboard.ContainsText Then PasteToolStripMenuItem.Enabled = True Else PasteToolStripMenuItem.Enabled = False End If End With End Sub

Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

Dim reader As New System.IO.StreamReader(file)

Dim RTBCurText = reader.ReadToEnd reader.Close()

If Not fIs.RtbEditor.Text = RTBCurText Then Dim writer As New

System.IO.StreamWriter(file, False) writer.Write(fIs.RtbEditor.Text) writer.Close() End If Else simpan() End If Else simpan() End If End Sub

Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAsToolStripMenuItem.Click

simpan() End Sub

Sub simpan()

Dim saveas As New SaveFileDialog With saveas .DefaultExt = ".html" .Filter = ("HTML Files(*.html)|*.html|php Files(*.php)|*.php|CSS(*.css)|*.css|js Files(*.js)|*.js|Text Documents(*.txt)|*.txt|INI Files(*.ini)|*.ini|BAT Files(*.bat)|*.bat|SQL Files(*.sql)|*.sql|All Files(*.*)|*.*")

.Title = "Simpan Berkas" End With

If saveas.ShowDialog = DialogResult.OK Then Dim writer As New

System.IO.StreamWriter(saveas.FileName, False) writer.Write(fIs.RtbEditor.Text) writer.Close() fIs.RtbEditor.Tag = saveas.FileName Tab.Text = My.Computer.FileSystem.GetFileInfo(saveas.FileName).Name

End Sub

Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged If TabControl1.TabCount > 0 Then Tab = TabControl1.SelectedTab fIs = TabControl1.SelectedTab.Tag fIs.RtbEditor.Focus() Timer2.Enabled = True menuAksi(True) fIs.RtbEditor.Focus() Else Timer2.Enabled = False UndoToolStripMenuItem.Enabled = False RedoToolStripMenuItem.Enabled = False CopyToolStripMenuItem.Enabled = False CutToolStripMenuItem.Enabled = False PasteToolStripMenuItem.Enabled = False fIs.RtbEditor.Focus() menuAksi(False) End If End Sub

Private Sub TutupTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

TutupTabToolStripMenuItem.Click tutuptab()

End Sub

Private Sub OpenToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click

Dim open As New OpenFileDialog With open .DefaultExt = ".html" .Filter = ("HTML Files(*.html)|*.html|php Files(*.php)|*.php|CSS(*.css)|*.css|js Files(*.js)|*.js|Text Documents(*.txt)|*.txt|INI Files(*.ini)|*.ini|BAT Files(*.bat)|*.bat|SQL Files(*.sql)|*.sql|All Files(*.*)|*.*")

.Title = "Buka Berkas" .Multiselect = True

AddTab(.FileNames(i)) Next

End If End With End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

ExitToolStripMenuItem.Click Me.Close()

End Sub

Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

UndoToolStripMenuItem.Click fIs.RtbEditor.Undo() End Sub

Private Sub RedoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

RedoToolStripMenuItem.Click fIs.RtbEditor.Redo() End Sub

Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

CopyToolStripMenuItem.Click fIs.RtbEditor.Copy() End Sub

Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

CutToolStripMenuItem.Click fIs.RtbEditor.Cut() End Sub

Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

PasteToolStripMenuItem.Click fIs.RtbEditor.Paste() End Sub

Dim fn As New FontDialog With fn .FontMustExist = True .MaxSize = 56 .MinSize = 8 .ShowApply = True .ShowEffects = True If .ShowDialog = Windows.Forms.DialogResult.OK Then fIs.RtbEditor.Font = .Font fIs.LblNomor.Font = .Font End If End With End Sub Sub tampil() If Tab.ToolTipText = "" Then

If MsgBox("Anda belum menyimpan file. Silahkan pilih yes untuk menyimpan", vbYesNoCancel, "Konfirmasi") = vbYes Then simpan() End If Else fIs.WBrHasil.Navigate(Tab.ToolTipText) End If End Sub

Private Sub HasliToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

HasliToolStripMenuItem.Click tampil()

End Sub

Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

AboutToolStripMenuItem.Click about.Enabled = True about.Visible = True End Sub

Private Function PreparePrintDocument() As Printing.PrintDocument

End Function

Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Dim Page As String

Page = fIs.RtbEditor.Text

e.Graphics.DrawString(Page, fIs.RtbEditor.Font, Brushes.Black, 50, 50)

e.HasMorePages = False End Sub

Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click

Dim Print_Preview As New PrintPreviewDialog Print_Preview.Icon = Me.Icon Print_Preview.Document = PreparePrintDocument() Print_Preview.WindowState = FormWindowState.Maximized Print_Preview.ShowDialog() End Sub

Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

PrintToolStripMenuItem.Click

Dim Print_Dialog As New PrintDialog

Print_Dialog.Document = PreparePrintDocument() Print_Dialog.ShowDialog() If Print_Dialog.ShowDialog = Windows.Forms.DialogResult.OK Then Print_Dialog.Document.Print() End If End Sub

Private Sub btnTutuptab_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTutuptab.Click tutuptab() End Sub Sub tutuptab() If fIs.RtbEditor.Text = "" Then TabControl1.TabPages.Remove(Tab) Else

to save

If msg = DialogResult.Yes Then simpan()

TabControl1.TabPages.Remove(Tab) ElseIf msg = DialogResult.No Then TabControl1.TabPages.Remove(Tab) End If

Else

Dim file As String = Tab.ToolTipText

If My.Computer.FileSystem.FileExists(file) Then

Dim reader As New System.IO.StreamReader(file)

Dim RTBCurText = reader.ReadToEnd reader.Close()

If Not fIs.RtbEditor.Text = RTBCurText Then

If MsgBox("Apakah anda ingin

menyimpan perubahan?", vbYesNo, "Konfirmasi") = vbYes Then Dim writer As New

System.IO.StreamWriter(file, False) writer.Write(fIs.RtbEditor.Text) writer.Close() TabControl1.TabPages.Remove(Tab) Else TabControl1.TabPages.Remove(Tab) End If End If End If TabControl1.TabPages.Remove(Tab) End If If TabControl1.TabCount = 0 Then btnTutuptab.Enabled = False btnTutuptab.Visible = False btnHasil.Enabled = False BtnSplit.Enabled = False btnText.Enabled = False End If End If End Sub

FrmCari.Enabled = True FrmCari.Visible = True End Sub

Private Sub about_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

' Set the title of the form. Dim ApplicationTitle As String

If My.Application.Info.Title <> "" Then ApplicationTitle = "About Editor HTML" Else ApplicationTitle = System.IO.Path.GetFileNameWithoutExtension(My.Application.In fo.AssemblyName) End If Me.Text = String.Format("About {0}", ApplicationTitle)

' Initialize all of the text displayed on the About Box.

' TODO: Customize the application's assembly information in the "Application" pane of the project

' properties dialog (under the "Project" menu). Me.LabelProductName.Text = "Editor HTML" Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString) Me.LabelCopyright.Text = "Copyright@herverydikxonsihombing2013" Me.LabelCompanyName.Text = "USU"

Me.TextBoxDescription.Text = "Program ini merupakan editor untuk berbagai file text, tapi kita mengutamakan untuk text dengan extensi html, Editor HTML ini dibuat sebagai syarat (TA) untuk diploma"

End Sub

Private Sub OKButton_Click(ByVal sender As

System.Object, ByVal e As System.EventArgs) Handles OKButton.Click

Me.Close() End Sub

Dokumen terkait