Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
open text - URL document from listbox and determin which fil
#1
Developers

My name is Bradley and I have been developing for 2 years now using visual basic 2008 express edition I am also a developer and use assembly programming language.

Problem

I have a listbox that displays all files in a spersific directory and already have the code for showing the files and there extentions the probelm I am faceing is when I go to open a file some are URL and some are .doc and it don't know which one to open I need a peace of code that will allow to be open the file and it automaticly detects its exttention so any file for .doc = moduel 1.main and for URL goes to moduel 2.main here is the code so far

Moduel 1

Module Module1
Code:
Sub Main()
        OpenMicrosoftWord("C:\Travel\" & Form1.ListBox1.SelectedItem.ToString)
    End Sub
    Private Sub OpenMicrosoftWord(ByVal f As String)
        Dim startInfo As New ProcessStartInfo
        startInfo.FileName = "WINWORD.EXE"
        startInfo.Arguments = f
        Process.Start(startInfo)
    End Sub
End Module

Moduel 2

Module Module2
Code:
Sub Main()
        Process.Start("C:\Travel\" & Form1.ListBox1.SelectedItem.ToString)
    End Sub
End Module

Load form1

Code:
For Each FileStr As String In IO.Directory.GetFiles("C:\Travel", "*.*")
            ListBox1.Items.Add(IO.Path.GetFileName(FileStr))
        Next

open Button1

Code:
If ListBox1.SelectedItem = "*.doc" Then
            Module1.Main()
        End If
        If ListBox1.SelectedItem = "*.URL" Then
            Module2.Main()
        End If

any thoughts on what I could do or that I am doing wrong will be appricated and notied

Many Thanks


Messages In This Thread
open text - URL document from listbox and determin which fil - by Bradley - 04-23-2012, 10:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Open Zip files into a listview box Worf 2 13,975 09-20-2014, 10:14 AM
Last Post: Worf
  Search ListBox + Convert ListBox.item to string brco900033 3 14,574 09-13-2012, 03:03 PM
Last Post: brandonio21
  Reading certain text from website. b_ongzhenyu 0 6,310 03-16-2012, 07:13 AM
Last Post: b_ongzhenyu
  Open a directory brco900033 6 22,442 11-09-2011, 09:32 PM
Last Post: chuckebaby

Forum Jump:


Users browsing this thread: 1 Guest(s)