Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Simple Visual Basic question ( headache)

Status
Not open for further replies.

cubdh23

New Member
Hi, I finally got my program to read the COMM port and save it to a file but i was wondering to view the data currently how do i make the picturebox scroll down? When data reaches the end of the picture box it doesnt show. How do i make it show. Using textbox i know u can use scroll down feature but it is headache because it screws up my data.
Monday = Prior Vs Clemens
 
Sorry, I can not help with your picture box problem, I have never seen a picture box used that way. That's not to say it cannot be done.

Anyway, I routinely use a text box to log and format status data in my programs. I thought I would offer up my code and maybe it would help.


'**********Write status to text box and status text file********

Public Sub AddStatus(ByRef AlphaCode As String, ByRef strStat As String)

'declare Public LineNum as Short in your global variables

'Write to text box, make sure you set the vertical scroll bar property
txtStatus.Text = strStat & Now & vbCrLf & txtStatus.Text
txtStatus.Refresh()
LineNum = LineNum + 1

If LineNum = 100 Then 'clear the txtStatus after 100 lines
txtStatus.Text = ""
LineNum = 1
End If

'Open the text file and write the status line
Dim FileNumber As Short
strStat = strStat + " <" & Now.Date & " | " & TimeOfDay & ">"
On Error GoTo LogFileError
FileNumber = FreeFile()

FileOpen(FileNumber, VB6.GetPath & "\Status.txt", OpenMode.Append)
PrintLine(FileNumber, AlphaCode, strStat)
PrintLine(FileNumber, vbCr)

FileClose()

Exit Sub

LogFileError:
MsgBox(Str(Err.Number) & ": " & Err.Description & ", Could not open log file", , "Error")
FileClose()


End Sub


Good luck


Go
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top