visual basic programming help

Talk about everything off topic (EXCEPT POLITICS). Keep it fun!
Post Reply
sharky
3D Angel Eyes (Moderator)
Posts: 1819
Joined: Fri May 25, 2007 4:08 am
Location: Italy
Contact:

visual basic programming help

Post by sharky »

hi guys! does somebody have an idea about why the following VB proggy crashes on opening in win vista? (works fine on xp, and yes, both have .net framework 3.5 installed)

the error it gives is: System.InvalidOperationException

any help apreciated.

thnx

Code: Select all

Imports System
Imports System.IO


Public Class form1
    Public Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Int32) As UShort

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



    Private Sub ufficiotecnico()
        Dim d As String
        Dim Folder As String = "0"
        Dim subf As String = "0"
        Dim search As String = TextBox1.Text
        If search = "" Then
            search = "qwertz"
        End If

        If (Directory.Exists("Z:\001 Progetti\2008")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2008", search & "*")
                Folder = d
            Next
        End If

        If (Directory.Exists("Z:\001 Progetti\2009")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2009", search & "*")
                Folder = d
            Next
        End If

        If (Directory.Exists("Z:\001 Progetti\2010")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2010", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("Z:\001 Progetti\2011")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2011", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("Z:\001 Progetti\2012")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2012", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("Z:\001 Progetti\2013")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2013", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("Z:\001 Progetti\2014")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2014", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("Z:\001 Progetti\2015")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2015", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("Z:\001 Progetti\2016")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2016", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("Z:\001 Progetti\2017")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2017", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("Z:\001 Progetti\2018")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2018", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("Z:\001 Progetti\2019")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2019", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("Z:\001 Progetti\2020")) Then
            For Each d In Directory.GetDirectories("Z:\001 Progetti\2020", search & "*")
                Folder = d
            Next
        End If


        If Folder <> "0" Then
            If ComboBox1.Text = "Disegni" Then
                subf = "01  Disegni"
            ElseIf ComboBox1.Text = "Documentazione" Then
                subf = "02  Documentazione"
            Else
                subf = "100  CD"
            End If

            Process.Start("explorer.exe", Folder & "\" & subf)
        Else
            MsgBox("Cartella non trovata.")
        End If

    End Sub



    Private Sub tecnicocomm()
        Dim d As String
        Dim Folder As String = "0"
        Dim search As String = TextBox2.Text
        If search = "" Then
            search = "qwertz"
        End If

        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2008")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2008", search & "*")
                Folder = d
            Next
        End If

        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2009")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2009", search & "*")
                Folder = d
            Next
        End If

        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2010")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2010", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2011")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2011", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2012")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2012", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2013")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2013", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2014")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2014", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2015")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2015", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2016")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2016", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2017")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2017", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2018")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2018", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2019")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2019", search & "*")
                Folder = d
            Next
        End If
        If (Directory.Exists("T:\001 Offerte\001 Offerte per Progetti\2020")) Then
            For Each d In Directory.GetDirectories("T:\001 Offerte\001 Offerte per Progetti\2020", search & "*")
                Folder = d
            Next
        End If


        If Folder <> "0" Then
            Process.Start("explorer.exe", Folder)
        Else
            MsgBox("Cartella non trovata.")
        End If

    End Sub



    Private Sub TextBox1_Textenter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.KeyDown

        If (GetAsyncKeyState(Keys.Enter)) Then
            Button1.Focus()
            ufficiotecnico()
        End If
    End Sub
    Private Sub TextBox2_Textenter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.KeyDown

        If (GetAsyncKeyState(Keys.Enter)) Then
            Button1.Focus()
            tecnicocomm()
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        tecnicocomm()

    End Sub
End Class

Adam Savage: "I reject your reality and substitute it for my own."
Jamie Hyneman: "It's really cool, but really unusual."

Image
User avatar
cirk2
Certif-Eyed!
Posts: 521
Joined: Fri May 11, 2007 10:13 am

Re: visual basic programming help

Post by cirk2 »

Hmm I have no plan about programming...

What are you trying? Serching some subfolders?

but have you tryed running it as Admin?
Image
sharky
3D Angel Eyes (Moderator)
Posts: 1819
Joined: Fri May 25, 2007 4:08 am
Location: Italy
Contact:

Re: visual basic programming help

Post by sharky »

we ahve a LOT of folders with a certain prefix and tehn a folder name. i want to open the folder that has that specific prefix.

yes i tried to run it as admin. it just crashes to windows... but works great on xp
Adam Savage: "I reject your reality and substitute it for my own."
Jamie Hyneman: "It's really cool, but really unusual."

Image
User avatar
cybereality
3D Angel Eyes (Moderator)
Posts: 11407
Joined: Sat Apr 12, 2008 8:18 pm

Re: visual basic programming help

Post by cybereality »

Visual basic... yuck...

Anyway, you could try running it in "compatibility mode" (right-click on the program, click the compatibility tab, then choose the OS you want to target). That might help. Also running as admin might also help as well.
sharky
3D Angel Eyes (Moderator)
Posts: 1819
Joined: Fri May 25, 2007 4:08 am
Location: Italy
Contact:

Re: visual basic programming help

Post by sharky »

found the problem. visual basic express (free) installs a power pack. everything inside that pack is not supposed to work on systems that dont have that pack installed. so i removed those elements and now it works-.
Adam Savage: "I reject your reality and substitute it for my own."
Jamie Hyneman: "It's really cool, but really unusual."

Image
Post Reply

Return to “General Discussion”