I am very new to VB.net I am not look for someone to just do it for me just send me in the Right direction I want to learn but I keep tripping up on Conversion from string "C:\Users\Zach\Desktop" to type 'Integer' is not valid. Please shed some light on my error.

Imports System
Imports System.IO
Imports System.Text
Imports System.IO.Directory

Public Class Form1

Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
    Me.Close()
End Sub

Private Sub PictureBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
    PictureBox1.Image = My.Resources.Exit_2
End Sub

Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
    PictureBox1.Image = My.Resources._Exit
End Sub

Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
    Process.Start("FILE NAME")
    MsgBox("Downloading Arma 3 Mods")
End Sub

Private Sub PictureBox2_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseEnter
    PictureBox2.Image = My.Resources.Download_2

End Sub

Private Sub PictureBox2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseLeave
    PictureBox2.Image = My.Resources.Download
End Sub

Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
    Call Console.WriteLine("GetFolderPath: eclipse", Environment.GetFolderPath(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)))
    Dim path As String = "eclipse"
    Dim path2 As String = "C:\Program Files (x86)"

    Try
        If File.Exists(path) = False Then
' This statement ensures that the file is created, 
' but the handle is not kept. 
Dim fs As FileStream = File.Create(Path)
            fs.Close()
        End If

' Ensure that the target does not exist. 
        If File.Exists(path2) Then
            File.Delete(path2)
        End If

' Move the file.
        File.Move(path, path2)
        Console.WriteLine("{8} moved to {1}", path, path2)

' See if the original file exists now. 
        If File.Exists(path) Then
            Console.WriteLine("The original file still exists, which is unexpected.")
        Else
            Console.WriteLine("The original file no longer exists, which is expected.")
        End If
    Finally
    End Try
End Sub


Private Sub PictureBox3_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox3.MouseEnter
    PictureBox3.Image = My.Resources.Move_File_2
End Sub

Private Sub PictureBox3_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox3.MouseLeave
    PictureBox3.Image = My.Resources.Move_File
End Sub

Class Sample
    Public Shared Sub Main()
        Console.WriteLine()
        Console.WriteLine("GetFolderPath: {0}", Environment.GetFolderPath(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)))
    End Sub 'Main
End Class 'Sample

End Class

Hi

A couple of things to note. Firstly, the syntax for getting the Desktop Directory is slightly off as you are calling GetFolderPath twice whereas it only needs to be done once as in:

Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))

This is the reason you are getting the Exception as the GetFolderPath expects an Integer which is supplied by the SpecialFolder enumeration but as you are calling it twice you are effectively passing the result of the inner GetFolderPath (which contains the string value of the location to your desktop) to the outer GetFolderPath which expects an Integer.

Secondly, the way you are using the Console.WriteLine in your statement suggests that you want to concatenate the DesktopDirectory value to your original string "GetFolderPath: eclipse". To do this, you need to add a place holder within this string where the output will be placed. See String.Format for more information, but essentially your code should look like:

Console.WriteLine("GetFolderPath: eclipse {0}", Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))

Thirdly, there is no need to use the Call keyword in this scenario and you should avoid using it unless it is absolutely necessary. In most cases you will not need to use this keyword. See Call Statement for more information and examples of when you would want to use it.

HTH

Thank you DJ that helped out alot I am afraid I have stumbled onto another problem here is the error I get. Index (zero based) must be greater than or equal to zero and less than the size of the argument list. Now i know its something to do with the {0} and {1} in the code and I am suppose to make a String.Format Line but I did that to no avail. Anymore tips I can get from you?

Imports System
Imports System.IO
Imports System.Text
Imports System.IO.Directory
Imports System.Runtime.InteropServices
Imports System.Security.Permissions
<Assembly: PermissionSetAttribute(SecurityAction.RequestMinimum, Name:="FullTrust")> 

Public Class Form1


    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        Me.Close()
    End Sub

    Private Sub PictureBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
        PictureBox1.Image = My.Resources.Exit_2
    End Sub

    Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
        PictureBox1.Image = My.Resources._Exit
    End Sub

    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        Process.Start("FILE NAME")
        MsgBox("Downloading Arma 3 Mods")
    End Sub

    Private Sub PictureBox2_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseEnter
        PictureBox2.Image = My.Resources.Download_2

    End Sub

    Private Sub PictureBox2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseLeave
        PictureBox2.Image = My.Resources.Download
    End Sub

    Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
        Console.WriteLine("GetFolderPath: eclipse {0}", Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
        Console.WriteLine("GetFolderPath: Program Files (x86) {1}", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)) 
        Dim path As String = "eclipse"
        Dim path2 As String = "Program Files"

        Try
            If File.Exists(path) = False Then
    ' This statement ensures that the file is created, 
    ' but the handle is not kept. 
    Dim fs As FileStream = File.Create(Path)
                fs.Close()
            End If

    ' Ensure that the target does not exist. 
            If File.Exists(path2) Then
                File.Delete(path2)
            End If

    ' Move the file.
            File.Move(path, path2)
            Console.WriteLine("{0} moved to {1}", path, path2)

    ' See if the original file exists now. 
            If File.Exists(path) Then
                Console.WriteLine("The original file still exists, which is unexpected.")
            Else
                Console.WriteLine("The original file no longer exists, which is expected.")
            End If
        Finally
        End Try
    End Sub


    Private Sub PictureBox3_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox3.MouseEnter
        PictureBox3.Image = My.Resources.Move_File_2
    End Sub

    Private Sub PictureBox3_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox3.MouseLeave
        PictureBox3.Image = My.Resources.Move_File
    End Sub
End Class

Hi

The String.Format method uses a zero based index. So in your code on line 40 this should be {0}.

Essentially, consider the following line

String.Format("My name is {0} and I am {1} years old", "DJ", "21")

This will print "My name is DJ and I am 21 years old"
(I wish)

However:

String.Format("My name is {1} and I am {2} years old", "DJ", "21")

Will result in the error that you received.

Also, note that the Console.WriteLine method allows you to use the String.Format without actually having to specify String.Format as in:

Console.WriteLine(("My name is {0} and I am {1} years old", "DJ", "21")

Finally, if you have more than 3 parameters then you will need to pass a parameter array. So for example:

Console.WriteLine("{0}", "{1}", "{2}", "{3}", New String() {"a", "b", "c", "d"})

The above creates a new string array and uses the {....} syntax to populate the array.

HTH

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.