It is currently Wed Jun 19, 2013 12:31 pm



Reply to topic  [ 5 posts ] 
 visual basic programming help 
Author Message
3D Angel Eyes (Moderator)
User avatar

Joined: Fri May 25, 2007 4:08 am
Posts: 1819
Location: Italy
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:
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


Wed Sep 23, 2009 8:02 am
Profile WWW
Certif-Eyed!
User avatar

Joined: Fri May 11, 2007 10:13 am
Posts: 521
Hmm I have no plan about programming...

What are you trying? Serching some subfolders?

but have you tryed running it as Admin?

_________________
Image


Wed Sep 23, 2009 8:22 am
Profile
3D Angel Eyes (Moderator)
User avatar

Joined: Fri May 25, 2007 4:08 am
Posts: 1819
Location: Italy
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


Wed Sep 23, 2009 8:30 am
Profile WWW
3D Angel Eyes (Moderator)
User avatar

Joined: Sat Apr 12, 2008 8:18 pm
Posts: 10155
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.

_________________
Image


Wed Sep 23, 2009 6:58 pm
Profile
3D Angel Eyes (Moderator)
User avatar

Joined: Fri May 25, 2007 4:08 am
Posts: 1819
Location: Italy
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


Thu Sep 24, 2009 4:57 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by STSoftware.