Click here to Skip to main content
15,901,505 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Best Way to handle foreign characters from XML to disk file Pin
QuickBooksDev3-May-07 3:58
QuickBooksDev3-May-07 3:58 
GeneralRe: Best Way to handle foreign characters from XML to disk file Pin
kubben3-May-07 4:34
kubben3-May-07 4:34 
GeneralRe: Best Way to handle foreign characters from XML to disk file Pin
QuickBooksDev3-May-07 4:35
QuickBooksDev3-May-07 4:35 
QuestionHow to convert a BitArray of length 8 into a single byte Pin
edmonson2-May-07 6:06
edmonson2-May-07 6:06 
AnswerRe: How to convert a BitArray of length 8 into a single byte Pin
Guffa2-May-07 6:24
Guffa2-May-07 6:24 
AnswerRe: How to convert a BitArray of length 8 into a single byte [modified] Pin
Dave Kreskowiak2-May-07 7:01
mveDave Kreskowiak2-May-07 7:01 
QuestionOpen file directly Pin
Xmen Real 2-May-07 5:23
professional Xmen Real 2-May-07 5:23 
AnswerRe: Open file directly Pin
Dave Kreskowiak2-May-07 5:51
mveDave Kreskowiak2-May-07 5:51 
Well, your code is looking for ".txt" on the command line. That's a bad assumption to make. If should just open the file it's given, no matter what the extension is. You're also trying to parse up the command line when you really don't have to. There's a method on the Environment class that returns al the command line arguments already parsed up:
Dim args As String() = Environment.GetCommandLineArgs()
If args.Length > 1 Then
    ' There's at least one argument, besides our .EXE filename
    ' Treat the first argument as a filename and try to open it as text file.
    LoadFile( args(1) )
End If
.
.


Private Sub LoadFile(ByVal filepath As String)
    Try
        If File.Exists(filepath) Then
            Text1.Text = File.ReadAllText(filepath)
        Else
            Throw New FileNotFoundException(String.Format("The filepath {0} was not found!", filepath))
        End If
    Catch ex As Exception
         ' Not exactly "good practice", but this works for this example...
        Throw ex
    End Try
End Sub

Now, if you're using a RichTextBox, there is no maximum size of text that can be read. If you're using a TextBox, you might want to check the MaxLength property and set it to 0 to indicate that there is no limit to maximum length of text in the box.


Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


GeneralRe: Open file directly [modified] Pin
Xmen Real 2-May-07 17:29
professional Xmen Real 2-May-07 17:29 
GeneralRe: Open file directly Pin
Dave Kreskowiak3-May-07 13:23
mveDave Kreskowiak3-May-07 13:23 
GeneralRe: Open file directly Pin
Xmen Real 3-May-07 18:18
professional Xmen Real 3-May-07 18:18 
QuestionVB printing problem Pin
Rich Leyshon2-May-07 4:42
Rich Leyshon2-May-07 4:42 
AnswerRe: VB printing problem Pin
Dave Kreskowiak2-May-07 6:23
mveDave Kreskowiak2-May-07 6:23 
GeneralRe: VB printing problem Pin
Rich Leyshon2-May-07 7:29
Rich Leyshon2-May-07 7:29 
GeneralRe: VB printing problem Pin
Rich Leyshon2-May-07 7:53
Rich Leyshon2-May-07 7:53 
QuestionOnly one window in the taskbar Pin
Jats_4ru2-May-07 4:38
Jats_4ru2-May-07 4:38 
AnswerRe: Only one window in the taskbar Pin
Psycho-*Coder*-Extreme2-May-07 4:51
Psycho-*Coder*-Extreme2-May-07 4:51 
AnswerRe: Only one window in the taskbar Pin
Dave Kreskowiak2-May-07 4:52
mveDave Kreskowiak2-May-07 4:52 
AnswerRe: Only one window in the taskbar Pin
Rupesh Kumar Swami2-May-07 5:02
Rupesh Kumar Swami2-May-07 5:02 
QuestionHow to close an application completely Pin
nahitan2-May-07 3:58
nahitan2-May-07 3:58 
AnswerRe: How to close an application completely Pin
Dave Kreskowiak2-May-07 4:03
mveDave Kreskowiak2-May-07 4:03 
GeneralRe: How to close an application completely Pin
nahitan2-May-07 4:07
nahitan2-May-07 4:07 
GeneralRe: How to close an application completely Pin
Dave Kreskowiak2-May-07 4:47
mveDave Kreskowiak2-May-07 4:47 
QuestionNeed Help with Outlook [modified] Pin
Jats_4ru2-May-07 3:08
Jats_4ru2-May-07 3:08 
AnswerRe: Need Help with Outlook Pin
RichardBerry2-May-07 3:40
RichardBerry2-May-07 3:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.