Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB crashes - memory could not be 'read' 1

Status
Not open for further replies.

JSD1976

Programmer
Aug 17, 2004
16
0
0
US
Hello,

I have recently encountered a problem with my VB6 application I'm creating. Every 5 minutes or so I get an error message:

The instruction at "0x0fc000e" referenced memory at "0x00000023." The memory could not be 'read.'

Then the program crashes. I have been modifying a free module from the interent, but this was not happening before. Can someone point me in the right direction of what this errror means so that I may correct this? It is quite annoying.

As always, thanks a bunch.

Jeremy
 
Are you (or the module) using CopyMemory anywhere? Or doing any subclassing?
 
Hello

I am not sure. How would I know? I am going to school to become a programmer but I'm afraid I don't know much yet. Most of my experience has been in VBA. I can post the code/ modules.

Module1:
Option Explicit

Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long

Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long

Global strReadString As String
Global acObject As ACOMPORTLib.ComPort

Sub TimerProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal idEvent As Long, _
ByVal dwTime As Long)

strReadString = acObject.ReadString
If strReadString <> "" Then
AComportDemo.TXT_Received = AComportDemo.TXT_Received & strReadString
End If
End Sub

Form Code:
Public lTimerID As Long

Private Sub BTN_Send_Click()
acObject.WriteString (1)
End Sub

Private Sub Form_Activate()
acObject.CTSRTS = 1
acObject.Open

If acObject.LastError = asERR_SUCCESS Then
lTimerID = SetTimer(0, 0, 500, AddressOf TimerProc)
If lTimerID = 0 Then
MsgBox "Could not create Timer"
End If
End If
End Sub
Private Sub Form_Deactivate()
acObject.Close

If lTimerID <> 0 Then
lTimerID = KillTimer(0, lTimerID)
lTimerID = 0
End If
End Sub
Private Sub Form_Load()
TXT_Send = ""

'CB_Port.AddItem "1"
'CB_Port.AddItem "2"
'CB_Port.AddItem "3"
'CB_Port.AddItem "4"
'CB_Port.ListIndex = 0


'CB_Baudrate.AddItem "110"
'CB_Baudrate.AddItem "300"
'CB_Baudrate.AddItem "600"
'CB_Baudrate.AddItem "1200"
'CB_Baudrate.AddItem "2400"
'CB_Baudrate.AddItem "4800"
'CB_Baudrate.AddItem "9600"
'CB_Baudrate.AddItem "14400"
'CB_Baudrate.AddItem "19200"
'CB_Baudrate.AddItem "38400"
'CB_Baudrate.AddItem "57600"
'CB_Baudrate.ListIndex = 6

'CB_FlowControl.AddItem "On"
'CB_FlowControl.AddItem "Off"
'CB_FlowControl.ListIndex = 0

Set acObject = CreateObject("ActiveXperts.ComPort")

TXT_Received = ""

lTimerID = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
If lTimerID <> 0 Then
lTimerID = KillTimer(0, lTimerID)
lTimerID = 0
End If
End Sub


 
Can you try adding

acObject.ComTimeout=200

(or any value smaller than used in SetTimer) at the end of the Form_Load sub


 
Thanks a bunch.

I haven't crashed for hours.

Ahhhh.........
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top