Computer Restarts everytime I try to do Serial Communication in VB6
I am new over here, it's my first post. I don't know much about Visual Basic 6, I have been good in C language and Assembly language of different machines. But I'm trying to get the hold of VB6 again. I had forget most of the programming, I used to do simple programming in it around 7 year ago or more.
My computer is Pentium Core 2 Quad with 2.40Ghz. My computer doesn't have Serial Port, so I am using a USB to Serial Converter, I have designed an electronic circuit attach to the serial port, which is dumping values in it @2400,8,n,1 baud rate. I had seen the output on hyperterminal, the circuit is working fine.Now I want my VB program to act like a hyperterminal, to show me the values being sent by my circuit. By the time I execute the program, the system restarts without ever showing any error message.It's annoying me a lot, before writing this Thread, I put back my old computer, Pentium III Compaq Presario 6000. As soon as I plug in the power cord, I heard a Boom in the power supply, I then saw the power supply selector switch into 115V from 230V. I didn't notice as if the power selector was changed from its position, now my working Pentium III power supply is dead now. It had it's own original Serial Port and Parallel Port, so if I run my VB6 program into the older machine with it's own serial port, this won't make my system crash, because I had seen that there are extra USBSerial.DLL files in my P4 computer, which doesn't have Serial port, it's a virtual Serial port, so it's driver might be causing the system to restart. So any suggestion as what should now I do about it. Any idea about it, I have to take out some time for my old computer to see how much damage it had brought to my machine.
Re: Computer Restarts everytime I try to do Serial Communication in VB6
Some questions here:
(1) What is your OS?
(2) Are you saying that the USB/Serial converter is working OK with Hyper Terminal?
(3) What version of VB6 are you using?
(4) Are you using MSComm packaged with VB or did you download it from a third party?
Re: Computer Restarts everytime I try to do Serial Communication in VB6
1) Windows Xp
Professional
Version 2002
Service Pack 2
2) Yes, you got that right. My USB to Serial converter works fine with hyperterminal and it displays the value correctly. I have also make sure about the baud rate,parity, stop bit and had set all of them correctly.
3) Microsoft Visual Basic 6.0
For 32-bit Windows Development
Version 8176
VBA:Retail 6.0.8169
Forms3: 12.0.4518.101
4) Yes, I am using MSComm control.
Here's my code:
Code:
Private Sub Command1_Click()
End
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
MSComm1.Output = KeyAscii
Text1.Text = KeyAscii
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 4
MSComm1.Settings = "2400,N,8,1"
MSComm1.InputLen = 0
MSComm1.Handshaking = comNone
MSComm1.PortOpen = True
End Sub
Private Sub MSComm1_OnComm()
If (MSComm1.CommEvent = comEvRecieve) Then
Text2.Text = MSComm1.Input
End If
End Sub
I want to add one more thing, I tried the above program, the system crashes without even giving the problem.The program that I had written got corrupted and VB6 isn't loading my program. It happened because every time I ran that program, system crashes. So in the end, the file got corrupted. So this is the first program that I tried for testing, this also restarts the computer.I shouldn't use the word crash over here, because crash is something different. It just restarts the computer.
I had repaired my computer back again :) , just one wrong selected button on Power Supply wasted both money and time. The computer guy checked up all the hardware including RAM,Drives,Processor,etc and only Power Supply unit came out to be faulty and was replaced with a newer one, now system is functioning. I know after this reply, it would take some time for the other people to read and give reply, in the mean time I would be installing the VB6 on my repaired computer with built in serial/parallel port and I just experience it if my same program runs fine on it or not.I hope to get into a conclusion soon and post it what I get on the website.
Re: Computer Restarts everytime I try to do Serial Communication in VB6
Since this anomaly doesn't occur when using Hyper Terminal I would guess that there's nothing wrong with the USB/Serial drivers. While your code is rather odd and using 'End' is not good programming practice, there is nothing in your code that would cause a system restart. It's more likely that something went wrong when VB was installed.
Here's an experiment for you. Find the port that your internal modem is assigned to. It's usually COM3. Then try to open it with MSComm. This will eliminate any question of the USB/Serial converter.
BTW, I have four (and still growing) USB/Serial converters and they all work seamlessly, as if I had real serial ports. Their primary use is with MSComm and Microcontrollers etc.
Code:
Option Explicit
Private Sub Command1_Click()
MSComm1.PortOpen = True
MSComm1.Output = "ATV1Q0" & Chr(13)
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 3
MSComm1.RThreshold = 1
End Sub
Private Sub MSComm1_OnComm()
If MSComm1.CommEvent = comEvReceive Then
MsgBox "The Modem responded with " & MSComm1.Input
MSComm1.PortOpen = False
End If
End Sub