Lees bestand uit
Het hele programma is hier onder te downloaden bij "Download alles" dit is de complete documentatie die je nodig hebt al wil je het programma aanpassen. Als je er wat leuks mee gedaan hebt, of verbeteringen heb kun je dat gewoon in het contacten formulier zetten. Ik zal er dan zo spoedig mogelijk naar kijken. Als je alleen het programma wilt downloaden kun je de .exe ook downloaden. Dit is alleen de toepassing en kan niet aangepast worden.
Met dit programma kun je een *.txt bestand openen, opnieuw laden, en opslaan en natuurlijk ook opslaan als.
Maar ook heeft dit programma een functie ingebouwt zodat je de data ook kunt verwerken. als je namelijk net als hier links op de foto aangeeft waar hij wat moet tekenen tekent hij het op je scherm.
Download Alles (Visual studio nodig!)
Download alleen het .exe bestand
Download het .txt tekstbestand
Met dit programma kun je een *.txt bestand openen, opnieuw laden, en opslaan en natuurlijk ook opslaan als.
Maar ook heeft dit programma een functie ingebouwt zodat je de data ook kunt verwerken. als je namelijk net als hier links op de foto aangeeft waar hij wat moet tekenen tekent hij het op je scherm.
Download Alles (Visual studio nodig!)
Download alleen het .exe bestand
Download het .txt tekstbestand
Het tekstbestand dat hier gebruikt is
Blue
200
100
20
30
200
100
20
30
De volledige code zoals in Visual Studio
' This code is written by Jelle Wie WWW.Jellewie.Weebly.Com
'
Public Class Form1
Dim FileName As String
Dim FileLine As String
Dim MSG As String
Dim PostionX As Integer
Dim Counter As Integer
Dim NewPicture As Integer
'Button - Open
Private Sub ButtonSelectOpen_Click(sender As Object, e As EventArgs) Handles ButtonOpen.Click
Dim sfd As New OpenFileDialog() ' this creates an instance of the SaveFileDialog called "sfd"
sfd.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
sfd.RestoreDirectory = True
If sfd.ShowDialog() = DialogResult.OK Then
Dim FileName As String = sfd.FileName
TextBox1.Text = FileName
Read()
End If
End Sub
'Button - Reload
Private Sub ButtonReload_Click(sender As Object, e As EventArgs) Handles ButtonReload.Click
Dim FileName As String = TextBox1.Text
Read()
End Sub
'Code - Open file
Sub Read()
Dim fileReader As System.IO.StreamReader
FileName = TextBox1.Text
RichTextBox1.Text = ""
On Error GoTo Handler
fileReader = My.Computer.FileSystem.OpenTextFileReader(FileName)
'1th line
FileLine = fileReader.ReadLine()
TextBoxLine1.Text = FileLine
RichTextBox1.Text &= FileLine & Chr(13)
'2nd line
FileLine = fileReader.ReadLine()
TextBoxLine2.Text = FileLine
RichTextBox1.Text &= FileLine & Chr(13)
'3rd line
FileLine = fileReader.ReadLine()
TextBoxLine3.Text = FileLine
RichTextBox1.Text &= FileLine & Chr(13)
'4th line
FileLine = fileReader.ReadLine()
TextBoxLine4.Text = FileLine
RichTextBox1.Text &= FileLine & Chr(13)
'5th line
FileLine = fileReader.ReadLine()
TextBoxLine5.Text = FileLine
RichTextBox1.Text &= FileLine & Chr(13)
'All other lines
FileLine = fileReader.ReadToEnd
RichTextBox1.Text &= FileLine
fileReader.Close()
Exit Sub
Handler:
MSG = "Error # " & Err.Number & Chr(13)
If Err.Number = 53 Then
MSG &= "Cant open a non-existing file, it doesn't exist"
ElseIf Err.Number = 5 Then
MSG &= "Dont know what file your talking about"
Else
MSG &= "No further information, Sorry :("
End If
MsgBox(MSG, , "JelleWie")
End Sub
'Button - Save
Private Sub ButtonSave_Click(sender As Object, e As EventArgs) Handles ButtonSave.Click
FileName = TextBox1.Text
SaveFile()
Read()
End Sub
'Button - Save as
Private Sub ButtonSaveAs_Click(sender As Object, e As EventArgs) Handles ButtonSaveAs.Click
Dim sfd As New SaveFileDialog() ' this creates an instance of the SaveFileDialog called "sfd"
sfd.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
sfd.FilterIndex = 1
sfd.RestoreDirectory = True
If sfd.ShowDialog() = DialogResult.OK Then
FileName = sfd.FileName ' retrieve the full path to the file selected by the user
SaveFile()
End If
End Sub
'Code - Save file
Sub SaveFile()
Dim sw As New System.IO.StreamWriter(FileName, False) ' create a StreamWriter with the FileName selected by the User
sw.WriteLine(RichTextBox1.Text) ' Write the contents of TextBox to the file
sw.Close() ' close the file
End Sub
'Action - Block reload button when no file selected
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = "" Then
ButtonReload.Enabled = False
Else
ButtonReload.Enabled = True
End If
End Sub
'Button - Execute
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MSG = ""
'Read 1th - Set color
If TextBoxLine1.Text = "Red" Then
PictureBox1.BackColor = Color.Red
ElseIf TextBoxLine1.Text = "Green" Then
PictureBox1.BackColor = Color.Green
ElseIf TextBoxLine1.Text = "None" Then
PictureBox1.BackColor = TextBox1.BackColor
ElseIf TextBoxLine1.Text = "Yellow" Then
PictureBox1.BackColor = Color.Yellow
ElseIf TextBoxLine1.Text = "Blue" Then
PictureBox1.BackColor = Color.Blue
ElseIf TextBoxLine1.Text = "Orange" Then
PictureBox1.BackColor = Color.Orange
Else
MSG = "#ERROR# Not a valid color" & Chr(13) & "Valid colors;" & Chr(13) & "Red, Greeen, None, Yellow, Blue, Orange" & Chr(13)
MsgBox(MSG)
End If
'Read 2nd and 3rd - The X and Y postion
On Error GoTo Handler
If TextBoxLine2.Text > 0 And TextBoxLine3.Text > 0 Then
PictureBox1.Location = New Point(TextBoxLine2.Text, TextBoxLine3.Text)
End If
'Read 4th and 5th - The X and Y size
If TextBoxLine4.Text > 0 And TextBoxLine5.Text > 0 Then
PictureBox1.Size = New System.Drawing.Size(TextBoxLine4.Text, TextBoxLine5.Text)
End If
Exit Sub
Handler:
MSG &= "#ERROR# Please give me valid numbers for the position and size" & Chr(13)
MsgBox(MSG)
End Sub
'==================================================
'==================================================
'========== Help codes ==========
'==================================================
'==================================================
'Stop Help
Sub StopHelp()
LabelHelp.Text = ""
LabelHelp.ForeColor = ButtonOpen.ForeColor
LabelHelp.BackColor = ButtonOpen.BackColor
LabelHelp.Location = New Point(12, 238)
End Sub
'Start Help
Sub StartHelp()
LabelHelp.ForeColor = Color.Red
LabelHelp.BackColor = Color.White
End Sub
'Help 1
Private Sub TextBoxLine1_MouseEnter(sender As Object, e As EventArgs) Handles TextBoxLine1.MouseEnter
LabelHelp.Location = New Point(TextBoxLine1.Location.X + 81, TextBoxLine1.Location.Y + 4)
LabelHelp.Text = "A Color"
StartHelp()
End Sub
Private Sub TextBoxLine1_MouseLeave(sender As Object, e As EventArgs) Handles TextBoxLine1.MouseLeave
StopHelp()
End Sub
'Help 2
Private Sub TextBoxLine2_MouseEnter(sender As Object, e As EventArgs) Handles TextBoxLine2.MouseEnter
LabelHelp.Location = New Point(TextBoxLine2.Location.X + 81, TextBoxLine2.Location.Y + 4)
LabelHelp.Text = "The X coords"
StartHelp()
End Sub
Private Sub TextBoxLine2_MouseLeave(sender As Object, e As EventArgs) Handles TextBoxLine2.MouseLeave
StopHelp()
End Sub
'Help 3
Private Sub TextBoxLine3_MouseEnter(sender As Object, e As EventArgs) Handles TextBoxLine3.MouseEnter
LabelHelp.Location = New Point(TextBoxLine3.Location.X + 81, TextBoxLine3.Location.Y + 4)
LabelHelp.Text = "The Y coords"
StartHelp()
End Sub
Private Sub TextBoxLine3_MouseLeave(sender As Object, e As EventArgs) Handles TextBoxLine3.MouseLeave
StopHelp()
End Sub
'Help 4
Private Sub TextBoxLine4_MouseEnter(sender As Object, e As EventArgs) Handles TextBoxLine4.MouseEnter
LabelHelp.Location = New Point(TextBoxLine4.Location.X + 81, TextBoxLine4.Location.Y + 4)
LabelHelp.Text = "Size X"
StartHelp()
End Sub
Private Sub TextBoxLine4_MouseLeave(sender As Object, e As EventArgs) Handles TextBoxLine4.MouseLeave
StopHelp()
End Sub
'Help 5
Private Sub TextBoxLine5_MouseEnter(sender As Object, e As EventArgs) Handles TextBoxLine5.MouseEnter
LabelHelp.Location = New Point(TextBoxLine5.Location.X + 81, TextBoxLine5.Location.Y + 4)
LabelHelp.Text = "Size Y"
StartHelp()
End Sub
Private Sub TextBoxLine5_MouseLeave(sender As Object, e As EventArgs) Handles TextBoxLine5.MouseLeave
StopHelp()
End Sub
End Class
'
Public Class Form1
Dim FileName As String
Dim FileLine As String
Dim MSG As String
Dim PostionX As Integer
Dim Counter As Integer
Dim NewPicture As Integer
'Button - Open
Private Sub ButtonSelectOpen_Click(sender As Object, e As EventArgs) Handles ButtonOpen.Click
Dim sfd As New OpenFileDialog() ' this creates an instance of the SaveFileDialog called "sfd"
sfd.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
sfd.RestoreDirectory = True
If sfd.ShowDialog() = DialogResult.OK Then
Dim FileName As String = sfd.FileName
TextBox1.Text = FileName
Read()
End If
End Sub
'Button - Reload
Private Sub ButtonReload_Click(sender As Object, e As EventArgs) Handles ButtonReload.Click
Dim FileName As String = TextBox1.Text
Read()
End Sub
'Code - Open file
Sub Read()
Dim fileReader As System.IO.StreamReader
FileName = TextBox1.Text
RichTextBox1.Text = ""
On Error GoTo Handler
fileReader = My.Computer.FileSystem.OpenTextFileReader(FileName)
'1th line
FileLine = fileReader.ReadLine()
TextBoxLine1.Text = FileLine
RichTextBox1.Text &= FileLine & Chr(13)
'2nd line
FileLine = fileReader.ReadLine()
TextBoxLine2.Text = FileLine
RichTextBox1.Text &= FileLine & Chr(13)
'3rd line
FileLine = fileReader.ReadLine()
TextBoxLine3.Text = FileLine
RichTextBox1.Text &= FileLine & Chr(13)
'4th line
FileLine = fileReader.ReadLine()
TextBoxLine4.Text = FileLine
RichTextBox1.Text &= FileLine & Chr(13)
'5th line
FileLine = fileReader.ReadLine()
TextBoxLine5.Text = FileLine
RichTextBox1.Text &= FileLine & Chr(13)
'All other lines
FileLine = fileReader.ReadToEnd
RichTextBox1.Text &= FileLine
fileReader.Close()
Exit Sub
Handler:
MSG = "Error # " & Err.Number & Chr(13)
If Err.Number = 53 Then
MSG &= "Cant open a non-existing file, it doesn't exist"
ElseIf Err.Number = 5 Then
MSG &= "Dont know what file your talking about"
Else
MSG &= "No further information, Sorry :("
End If
MsgBox(MSG, , "JelleWie")
End Sub
'Button - Save
Private Sub ButtonSave_Click(sender As Object, e As EventArgs) Handles ButtonSave.Click
FileName = TextBox1.Text
SaveFile()
Read()
End Sub
'Button - Save as
Private Sub ButtonSaveAs_Click(sender As Object, e As EventArgs) Handles ButtonSaveAs.Click
Dim sfd As New SaveFileDialog() ' this creates an instance of the SaveFileDialog called "sfd"
sfd.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
sfd.FilterIndex = 1
sfd.RestoreDirectory = True
If sfd.ShowDialog() = DialogResult.OK Then
FileName = sfd.FileName ' retrieve the full path to the file selected by the user
SaveFile()
End If
End Sub
'Code - Save file
Sub SaveFile()
Dim sw As New System.IO.StreamWriter(FileName, False) ' create a StreamWriter with the FileName selected by the User
sw.WriteLine(RichTextBox1.Text) ' Write the contents of TextBox to the file
sw.Close() ' close the file
End Sub
'Action - Block reload button when no file selected
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = "" Then
ButtonReload.Enabled = False
Else
ButtonReload.Enabled = True
End If
End Sub
'Button - Execute
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MSG = ""
'Read 1th - Set color
If TextBoxLine1.Text = "Red" Then
PictureBox1.BackColor = Color.Red
ElseIf TextBoxLine1.Text = "Green" Then
PictureBox1.BackColor = Color.Green
ElseIf TextBoxLine1.Text = "None" Then
PictureBox1.BackColor = TextBox1.BackColor
ElseIf TextBoxLine1.Text = "Yellow" Then
PictureBox1.BackColor = Color.Yellow
ElseIf TextBoxLine1.Text = "Blue" Then
PictureBox1.BackColor = Color.Blue
ElseIf TextBoxLine1.Text = "Orange" Then
PictureBox1.BackColor = Color.Orange
Else
MSG = "#ERROR# Not a valid color" & Chr(13) & "Valid colors;" & Chr(13) & "Red, Greeen, None, Yellow, Blue, Orange" & Chr(13)
MsgBox(MSG)
End If
'Read 2nd and 3rd - The X and Y postion
On Error GoTo Handler
If TextBoxLine2.Text > 0 And TextBoxLine3.Text > 0 Then
PictureBox1.Location = New Point(TextBoxLine2.Text, TextBoxLine3.Text)
End If
'Read 4th and 5th - The X and Y size
If TextBoxLine4.Text > 0 And TextBoxLine5.Text > 0 Then
PictureBox1.Size = New System.Drawing.Size(TextBoxLine4.Text, TextBoxLine5.Text)
End If
Exit Sub
Handler:
MSG &= "#ERROR# Please give me valid numbers for the position and size" & Chr(13)
MsgBox(MSG)
End Sub
'==================================================
'==================================================
'========== Help codes ==========
'==================================================
'==================================================
'Stop Help
Sub StopHelp()
LabelHelp.Text = ""
LabelHelp.ForeColor = ButtonOpen.ForeColor
LabelHelp.BackColor = ButtonOpen.BackColor
LabelHelp.Location = New Point(12, 238)
End Sub
'Start Help
Sub StartHelp()
LabelHelp.ForeColor = Color.Red
LabelHelp.BackColor = Color.White
End Sub
'Help 1
Private Sub TextBoxLine1_MouseEnter(sender As Object, e As EventArgs) Handles TextBoxLine1.MouseEnter
LabelHelp.Location = New Point(TextBoxLine1.Location.X + 81, TextBoxLine1.Location.Y + 4)
LabelHelp.Text = "A Color"
StartHelp()
End Sub
Private Sub TextBoxLine1_MouseLeave(sender As Object, e As EventArgs) Handles TextBoxLine1.MouseLeave
StopHelp()
End Sub
'Help 2
Private Sub TextBoxLine2_MouseEnter(sender As Object, e As EventArgs) Handles TextBoxLine2.MouseEnter
LabelHelp.Location = New Point(TextBoxLine2.Location.X + 81, TextBoxLine2.Location.Y + 4)
LabelHelp.Text = "The X coords"
StartHelp()
End Sub
Private Sub TextBoxLine2_MouseLeave(sender As Object, e As EventArgs) Handles TextBoxLine2.MouseLeave
StopHelp()
End Sub
'Help 3
Private Sub TextBoxLine3_MouseEnter(sender As Object, e As EventArgs) Handles TextBoxLine3.MouseEnter
LabelHelp.Location = New Point(TextBoxLine3.Location.X + 81, TextBoxLine3.Location.Y + 4)
LabelHelp.Text = "The Y coords"
StartHelp()
End Sub
Private Sub TextBoxLine3_MouseLeave(sender As Object, e As EventArgs) Handles TextBoxLine3.MouseLeave
StopHelp()
End Sub
'Help 4
Private Sub TextBoxLine4_MouseEnter(sender As Object, e As EventArgs) Handles TextBoxLine4.MouseEnter
LabelHelp.Location = New Point(TextBoxLine4.Location.X + 81, TextBoxLine4.Location.Y + 4)
LabelHelp.Text = "Size X"
StartHelp()
End Sub
Private Sub TextBoxLine4_MouseLeave(sender As Object, e As EventArgs) Handles TextBoxLine4.MouseLeave
StopHelp()
End Sub
'Help 5
Private Sub TextBoxLine5_MouseEnter(sender As Object, e As EventArgs) Handles TextBoxLine5.MouseEnter
LabelHelp.Location = New Point(TextBoxLine5.Location.X + 81, TextBoxLine5.Location.Y + 4)
LabelHelp.Text = "Size Y"
StartHelp()
End Sub
Private Sub TextBoxLine5_MouseLeave(sender As Object, e As EventArgs) Handles TextBoxLine5.MouseLeave
StopHelp()
End Sub
End Class