Click here to Skip to main content
15,896,359 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Using Crystal Control in VB.net As VB6 Pin
Paul Conrad30-Dec-07 10:44
professionalPaul Conrad30-Dec-07 10:44 
QuestionVB.net, Web Services and Soap Pin
Brit the Brut26-Dec-07 16:52
Brit the Brut26-Dec-07 16:52 
GeneralRe: VB.net, Web Services and Soap Pin
Dave Kreskowiak27-Dec-07 12:38
mveDave Kreskowiak27-Dec-07 12:38 
Generalneed help selecting rows in a DataGridView Pin
Shimmy Weitzhandler26-Dec-07 15:42
Shimmy Weitzhandler26-Dec-07 15:42 
GeneralRe: need help selecting rows in a DataGridView Pin
helelark12326-Dec-07 19:27
helelark12326-Dec-07 19:27 
GeneralRe: need help selecting rows in a DataGridView Pin
Shimmy Weitzhandler29-Dec-07 7:49
Shimmy Weitzhandler29-Dec-07 7:49 
AnswerRe: need help selecting rows in a DataGridView [modified] Pin
Shimmy Weitzhandler30-Dec-07 13:53
Shimmy Weitzhandler30-Dec-07 13:53 
QuestionWriting to and reading from a text file Pin
Hedo26-Dec-07 15:12
Hedo26-Dec-07 15:12 
I've been trying to get this to work for weeks now without success.
I have two rich text boxes on my form and I'm trying to create a load_event so that
each one of the rich text boxes reads from a different text file saved on the root of C drive.
The richTextBox1 is working fine but richTextBox2 is not? What am I doing wrong?

Also, when F5 key is pressed(shortcut for MainMenuItem1) the following needs to happen:
the time stamp is put into whichever box has focus and the contents of that box need to be written
to a text file on C drive. All of this is working fine for richTextBox1 but not for richTextBox2.

Can anyone please help me??? I would greatly appreciate it!
Thanks, Hedo


Public Class Form1
Inherits System.Windows.Forms.Form
Dim firsthasfocus As Boolean
Dim secondhasfocus As Boolean



'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem2})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.Shortcut = System.Windows.Forms.Shortcut.F5
Me.MenuItem1.Text = "DateTimeStamp"
Me.MenuItem1.Visible = False




Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click

If firsthasfocus Then
richTextBox1.Text = richTextBox1.Text & " " & Now & " "
ElseIf secondhasfocus Then

RichTextBox2.Text = RichTextBox2.Text & " " & Now & " "

Dim richTextBox1 As New RichTextBox

End If

Dim FILE_NAME As String = "C:\textfile1.txt"
If System.IO.File.Exists("C:\textfile1.txt") = True Then
'The following line of code will overwrite the log with the current
'contents of the text box(when F5 key is pressed),
'if you wish to append(add) text instead of
'overwriting it then just add "True" in the parenthesis after the path
' so it looks like this("C:\textfile1.txt", True)
Dim objWriter As New System.IO.StreamWriter("C:\textfile1.txt")
objWriter.Write(richTextBox1.Text)
objWriter.Close()
MsgBox("Saved")
Else
MsgBox("File Does Not Exist")
End If


End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim FILE_NAME As String = "C:\textfile1.txt""C:\textfile1.txt"
If System.IO.File.Exists("C:\textfile1.txt") = True Then
Dim objReader As New System.IO.StreamReader("C:\textfile1.txt")
RichTextBox1.Text = objReader.ReadToEnd
objReader.Close()
End If
If System.IO.File.Exists("C:\textfile2.txt") = True Then
Dim objReader As New System.IO.StreamReader("C:\textfile2.txt")
RichTextBox2.Text = objReader.ReadToEnd
objReader.Close()
Else
MsgBox("File Does Not Exist")
End If



End Sub

Private Sub RichTextBox2_GotFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox2.GotFocus
secondhasfocus = True
firsthasfocus = False

End Sub
GeneralRe: Writing to and reading from a text file Pin
helelark12326-Dec-07 19:44
helelark12326-Dec-07 19:44 
GeneralRe: Writing to and reading from a text file Pin
Hedo27-Dec-07 16:55
Hedo27-Dec-07 16:55 
QuestionMouse Movement in VB 6.0 Pin
zawpai26-Dec-07 14:59
zawpai26-Dec-07 14:59 
GeneralRe: Mouse Movement in VB 6.0 Pin
Dave Kreskowiak27-Dec-07 12:27
mveDave Kreskowiak27-Dec-07 12:27 
Question[Message Deleted] Pin
ciconte26-Dec-07 14:28
ciconte26-Dec-07 14:28 
GeneralRe: Terms of use and e-mail subscription Pin
Dave Kreskowiak27-Dec-07 12:21
mveDave Kreskowiak27-Dec-07 12:21 
GeneralRe: [Message Deleted] Pin
Paul Conrad30-Dec-07 10:45
professionalPaul Conrad30-Dec-07 10:45 
GeneralExport Excel Sheet to Textfile (vb.net) Pin
Member 375080126-Dec-07 13:45
Member 375080126-Dec-07 13:45 
GeneralRe: Export Excel Sheet to Textfile (vb.net) Pin
Paul Conrad30-Dec-07 10:46
professionalPaul Conrad30-Dec-07 10:46 
QuestionRe: Export Excel Sheet to Textfile (vb.net) Pin
Member 37508012-Jan-08 7:08
Member 37508012-Jan-08 7:08 
GeneralBetter way of connecting to SQL 2005 Pin
svanwass26-Dec-07 13:31
svanwass26-Dec-07 13:31 
GeneralRe: Better way of connecting to SQL 2005 Pin
Dave Kreskowiak27-Dec-07 12:17
mveDave Kreskowiak27-Dec-07 12:17 
QuestionClass disposal Pin
__OZ__26-Dec-07 10:33
__OZ__26-Dec-07 10:33 
GeneralRe: Class disposal Pin
Dave Kreskowiak26-Dec-07 10:59
mveDave Kreskowiak26-Dec-07 10:59 
GeneralRe: Class disposal Pin
__OZ__26-Dec-07 15:10
__OZ__26-Dec-07 15:10 
GeneralRe: Class disposal Pin
Scott Dorman26-Dec-07 17:55
professionalScott Dorman26-Dec-07 17:55 
QuestionHow to work with Collection in VB6? Pin
suguimoto26-Dec-07 6:48
suguimoto26-Dec-07 6:48 

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.