Click here to Skip to main content
14,697,595 members
Home » Discussions » Visual Basic
   

Visual Basic

 
GeneralRe: Best Way to handle foreign characters from XML to disk file Pin
QuickBooksDev3-May-07 4:58
MemberQuickBooksDev3-May-07 4:58 
GeneralRe: Best Way to handle foreign characters from XML to disk file Pin
kubben3-May-07 5:34
Memberkubben3-May-07 5:34 
GeneralRe: Best Way to handle foreign characters from XML to disk file Pin
QuickBooksDev3-May-07 5:35
MemberQuickBooksDev3-May-07 5:35 
QuestionHow to convert a BitArray of length 8 into a single byte Pin
edmonson2-May-07 7:06
Memberedmonson2-May-07 7:06 
AnswerRe: How to convert a BitArray of length 8 into a single byte Pin
Guffa2-May-07 7:24
MemberGuffa2-May-07 7:24 
AnswerRe: How to convert a BitArray of length 8 into a single byte [modified] Pin
Dave Kreskowiak2-May-07 8:01
mveDave Kreskowiak2-May-07 8:01 
QuestionOpen file directly Pin
Xmen Real 2-May-07 6:23
professional Xmen Real 2-May-07 6:23 
AnswerRe: Open file directly Pin
Dave Kreskowiak2-May-07 6:51
mveDave Kreskowiak2-May-07 6: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 18:29
professional Xmen Real 2-May-07 18:29 
GeneralRe: Open file directly Pin
Dave Kreskowiak3-May-07 14:23
mveDave Kreskowiak3-May-07 14:23 
GeneralRe: Open file directly Pin
Xmen Real 3-May-07 19:18
professional Xmen Real 3-May-07 19:18 
QuestionVB printing problem Pin
Rich Leyshon2-May-07 5:42
MemberRich Leyshon2-May-07 5:42 
AnswerRe: VB printing problem Pin
Dave Kreskowiak2-May-07 7:23
mveDave Kreskowiak2-May-07 7:23 
GeneralRe: VB printing problem Pin
Rich Leyshon2-May-07 8:29
MemberRich Leyshon2-May-07 8:29 
GeneralRe: VB printing problem Pin
Rich Leyshon2-May-07 8:53
MemberRich Leyshon2-May-07 8:53 
QuestionOnly one window in the taskbar Pin
Jats_4ru2-May-07 5:38
MemberJats_4ru2-May-07 5:38 
AnswerRe: Only one window in the taskbar Pin
Psycho-*Coder*-Extreme2-May-07 5:51
MemberPsycho-*Coder*-Extreme2-May-07 5:51 
AnswerRe: Only one window in the taskbar Pin
Dave Kreskowiak2-May-07 5:52
mveDave Kreskowiak2-May-07 5:52 
AnswerRe: Only one window in the taskbar Pin
Rupesh Kumar Swami2-May-07 6:02
MemberRupesh Kumar Swami2-May-07 6:02 
QuestionHow to close an application completely Pin
nahitan2-May-07 4:58
Membernahitan2-May-07 4:58 
AnswerRe: How to close an application completely Pin
Dave Kreskowiak2-May-07 5:03
mveDave Kreskowiak2-May-07 5:03 
GeneralRe: How to close an application completely Pin
nahitan2-May-07 5:07
Membernahitan2-May-07 5:07 
GeneralRe: How to close an application completely Pin
Dave Kreskowiak2-May-07 5:47
mveDave Kreskowiak2-May-07 5:47 
QuestionNeed Help with Outlook [modified] Pin
Jats_4ru2-May-07 4:08
MemberJats_4ru2-May-07 4:08 
AnswerRe: Need Help with Outlook Pin
RichardBerry2-May-07 4:40
MemberRichardBerry2-May-07 4: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.