You are viewing our Forum Archives. To view or take place in current topics click here.
New Program I Made!!
Posted:

New Program I Made!!Posted:

joeisjoe5
  • Rising Star
Status: Offline
Joined: Jun 18, 201212Year Member
Posts: 775
Reputation Power: 31
Status: Offline
Joined: Jun 18, 201212Year Member
Posts: 775
Reputation Power: 31
Hi, so I recently finished a program I made which allows me to upload a picture on a specific day then when I choose that date on the selector, it shows me that picture. I made this because I am going to get another bearded dragon, and everyday I will take a picture of it and then upload it, then if I want to see how big he was and stuff on a specific date, i can choose that date and it will show me the picture from that day.

Screenshots:
[ Register or Signin to view external links. ]
[ Register or Signin to view external links. ]
[ Register or Signin to view external links. ]

Code:
Imports System.IO
Public Class Form1
    Function GetUserName() As String
        If TypeOf My.User.CurrentPrincipal Is
          Security.Principal.WindowsPrincipal Then
            Dim parts() As String = Split(My.User.Name, "\")
            Dim username As String = parts(1)
            Return username
        Else
            Return My.User.Name
        End If
    End Function
    Function GetDrive()
        Return (Path.GetPathRoot(My.Application.Info.DirectoryPath))
    End Function
    Sub updateSL()
        If TextBox1.Text <> currentSL Then
            Dim response As String
            response = MsgBox("Are you sure you want to change the save location for the program files?", vbYesNo, "Confirm?")

            If response = vbYes Then
                saveLocation = TextBox1.Text
                oldSL = currentSL
                currentSL = TextBox1.Text
                Dim FileName As String = saveLocation & "\imageLocations.txt"
                IO.File.WriteAllLines(FileName, imageLocations)
                FileName = saveLocation & "\pairedDate.txt"
                IO.File.WriteAllLines(FileName, pairedDate)
                Kill(oldSL & "\imageLocations.txt")
                Kill(oldSL & "\pairedDate.txt")
            Else
                TextBox1.Text = saveLocation
            End If
        End If
    End Sub
    Sub updatePic()
        Dim currentDate As String = Mid(DateTimePicker1.Value, 1, 10)
        For x = 0 To 10000
            pairedDate(x) = Mid(pairedDate(x), 1, 10)
            If pairedDate(x) = currentDate Then
                PictureBox1.ImageLocation = imageLocations(x)
                Exit For
            Else
                PictureBox1.Image = PictureBox1.ErrorImage
            End If
        Next
    End Sub
    Public imageLocations(10000), pairedDate(10000), saveLocation, currentSL, oldSL As String
    Public storedPictures, copyingfilescounter As Integer
    Public containsfile(10000) As Boolean
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        saveLocation = My.Settings.PFSL
        If saveLocation = "" Then saveLocation = GetDrive() & "Users\" & GetUserName() & "\Desktop"
        TextBox1.Text = saveLocation
        currentSL = saveLocation
        Dim FileName As String = saveLocation & "\imageLocations.txt"
        If File.ReadAllText(FileName) <> "" Then
            imageLocations = File.ReadAllLines(FileName)
            storedPictures = My.Settings.storedPictures
            FileName = saveLocation & "\pairedDate.txt"
            pairedDate = File.ReadAllLines(FileName)
        End If
        updatePic()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        updateSL()
        OpenFileDialog1.ShowDialog()
    End Sub

    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        Dim count As Integer
        Dim currentDate As String = Mid(DateTimePicker1.Value, 1, 10)
        For x = 0 To 10000
            pairedDate(x) = Mid(pairedDate(x), 1, 10)
            If pairedDate(x) = currentDate Then
                imageLocations(x) = OpenFileDialog1.FileName
                Exit For
            Else
                count = count + 1
            End If
        Next
        If count = 10001 Then
            imageLocations(storedPictures) = OpenFileDialog1.FileName
            pairedDate(storedPictures) = DateTimePicker1.Value
            storedPictures = storedPictures + 1
        End If
        PictureBox1.ImageLocation = OpenFileDialog1.FileName
    End Sub

    Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
        updatePic()
    End Sub

    Private Sub Form1_Deactivate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Deactivate
        My.Settings.storedPictures = storedPictures
        My.Settings.PFSL = saveLocation
        Dim FileName As String = saveLocation & "\imageLocations.txt"
        IO.File.WriteAllLines(FileName, imageLocations)
        FileName = saveLocation & "\pairedDate.txt"
        IO.File.WriteAllLines(FileName, pairedDate)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        updateSL()
        If ImgLoc() <> "NoImage" Then
            SaveFileDialog1.FileName = Replace(Mid(DateTimePicker1.Value, 1, 10), "/", "-")
            SaveFileDialog1.ShowDialog()
        Else
            MessageBox.Show("No image to save")
        End If
    End Sub
    Function ImgLoc()
        Dim currentDate As String = Mid(DateTimePicker1.Value, 1, 10)
        Dim returnValue As String = "NoImage"
        For x = 0 To 10000
            pairedDate(x) = Mid(pairedDate(x), 1, 10)
            If pairedDate(x) = currentDate Then
                returnValue = imageLocations(x)
                Exit For
            End If
        Next
        Return (returnValue)
    End Function

    Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
        My.Computer.FileSystem.CopyFile(ImgLoc, SaveFileDialog1.FileName, Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)
    End Sub
    Private Sub TextBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Enter
        currentSL = TextBox1.Text
    End Sub

    Private Sub Form1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
        updateSL()
    End Sub

    Private Sub Label1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
        updateSL()
    End Sub

    Private Sub DateTimePicker1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DateTimePicker1.MouseDown
        updateSL()
    End Sub

    Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
        updateSL()
    End Sub

    Private Sub Label2_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label2.MouseDown
        updateSL()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim currentDate As String = Mid(DateTimePicker1.Value, 1, 10)
        Dim count As Integer
        For x = 0 To 10000
            pairedDate(x) = Mid(pairedDate(x), 1, 10)
            If pairedDate(x) = currentDate Then
                Dim aresponse = MsgBox("Are you sure you want to delete this picture, this action can't be undone?", vbYesNo, "Confirm?")
                If aresponse = vbYes Then
                    imageLocations(x) = ""
                    pairedDate(x) = ""
                    storedPictures = storedPictures - 1
                    PictureBox1.Image = PictureBox1.ErrorImage
                    Exit For
                End If
            Else
                count = count + 1
            End If
        Next
        If count = 10001 Then
            MessageBox.Show("No Image to Delete")
        End If

    End Sub
End Class


What do you think of my little program?

The following 2 users thanked joeisjoe5 for this useful post:

Barn (09-23-2013), Experiment5X (09-22-2013)
#2. Posted:
joeisjoe5
  • Rising Star
Status: Offline
Joined: Jun 18, 201212Year Member
Posts: 775
Reputation Power: 31
Status: Offline
Joined: Jun 18, 201212Year Member
Posts: 775
Reputation Power: 31
I have added the code to the post
#3. Posted:
ModdingCandy
  • Ladder Climber
Status: Offline
Joined: Jul 26, 201212Year Member
Posts: 357
Reputation Power: 19
Status: Offline
Joined: Jul 26, 201212Year Member
Posts: 357
Reputation Power: 19
Its extremely basic, but a perfect program for beginners to work off of. Nice share.
#4. Posted:
GunSwoozy
  • Wise One
Status: Offline
Joined: Apr 04, 201212Year Member
Posts: 598
Reputation Power: 24
Status: Offline
Joined: Apr 04, 201212Year Member
Posts: 598
Reputation Power: 24
I've been programming in C# and I learned how to make something like that. Cool bro.
#5. Posted:
vRice
  • 2 Million
Status: Offline
Joined: Dec 17, 201112Year Member
Posts: 823
Reputation Power: 41
Status: Offline
Joined: Dec 17, 201112Year Member
Posts: 823
Reputation Power: 41
This is actually a really cool idea, simple, but cool.
:cat:
#6. Posted:
ip
  • Gold Gifter
Status: Offline
Joined: Dec 30, 201211Year Member
Posts: 3,778
Reputation Power: 3016
Status: Offline
Joined: Dec 30, 201211Year Member
Posts: 3,778
Reputation Power: 3016
Good job on it.
It is simple and a great program to help out the creator.
Good luck on your other programs!
#7. Posted:
Invicies
  • Challenger
Status: Offline
Joined: Jul 18, 201212Year Member
Posts: 108
Reputation Power: 4
Status: Offline
Joined: Jul 18, 201212Year Member
Posts: 108
Reputation Power: 4
So this is for monitoring your Lizards? Interesting. Is the source Obfiscuated?
#8. Posted:
joeisjoe5
  • Rising Star
Status: Offline
Joined: Jun 18, 201212Year Member
Posts: 775
Reputation Power: 31
Status: Offline
Joined: Jun 18, 201212Year Member
Posts: 775
Reputation Power: 31
Invicies wrote So this is for monitoring your Lizards? Interesting. Is the source Obfiscuated?


yh its just something I made so I can see my lizard, what do you mean obfiscuated?
#9. Posted:
joeisjoe5
  • Rising Star
Status: Offline
Joined: Jun 18, 201212Year Member
Posts: 775
Reputation Power: 31
Status: Offline
Joined: Jun 18, 201212Year Member
Posts: 775
Reputation Power: 31
AWL wrote Good job on it.
It is simple and a great program to help out the creator.
Good luck on your other programs!


Thanks, I hope to make some more programs soon
#10. Posted:
joeisjoe5
  • Rising Star
Status: Offline
Joined: Jun 18, 201212Year Member
Posts: 775
Reputation Power: 31
Status: Offline
Joined: Jun 18, 201212Year Member
Posts: 775
Reputation Power: 31
SimpleGfx wrote
This is actually a really cool idea, simple, but cool.
:cat:


Thank you, I just decided it would be a good idea for when I get it
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.