Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Visual Basic

See Related Forum Messages: Follow the Links Below to View Complete Thread

Connect COMM Port Of One Computer To Mouse Port Of Another
I would like to control the mouse of one computer with commands sent through the COMM port of another computer. This would allow me to automatically run certain data acquisition programs on the second computer withoun my having to point and click. I've been searching for information about this in the forums and on the web, but I haven't found anything. Any help would be appreciated.

Reset / Restart Timer

is it possible to reset the value of a timer back to zero


VB6/Word Comm Add In Won't Restart
I can run it the first time with no problem, but the second time I run it it won't run at all. Anyone have any ideas as to why this might be?


How Do I Reset / Restart A Winsock Control?
Edit by Moderator: Start your own threads please

Question about the winsock array. Ive seen people make controls on the form where its only winsock(0) then in the code they will open multiple connections such as

for i = 1 to 100
next i

So its like using 100 different connections. When i tried that, make a control on the form and making it into an array and just called winsock(0), it says that its out of bounds because that control doesnt exist. What special things do you need to do to get this to work.

How Do I Reset / Restart A Winsock Control?
I am creating a game server, and I want a Winsock control that can receive connections, then reply to the client to connect to a new port thats available on the server, (then increase the PortAvailable variable by +1) then reset the Winsock so it can receive a new connection. How do I do this?


I got multiple connections to work. I made copies of a simple Winsock client that connects to the server, and got validation both client and serverside for the connection. However, when I try to read the Ip address of the client (testing with msgbox in code), I get a blank msgbox.
Then I added

listen.accept requestID
at the beginning of the sub and
at the end -- and the IP works now. Now I can make one connection but future connections get forcefully rejected. How do I reset the listen Winsock so I can make more connections to it

Controls are listen.winsock and Winsock(0).Winsock and Winsock(1).Winsock on the form.

Dim ip(200) As String
Dim zz As Long

Private Sub Form_Load()

listen.LocalPort = 10104


End Sub

Private Sub listen_ConnectionRequest(ByVal requestID As Long)

listen.Accept requestID

Dim newsockka As Boolean
' Winsock.Close

newsock = 0
If Winsock.UBound > 2 Then
'onehundred =
For zz = 1 To Winsock.UBound
If Winsock(zz).RemoteHostIP = "" Then
newsock = zz
newsockka = 0
GoTo outofz
End If
If zz = Winsock.UBound Then
newsockka = 1
zz = zz + 1
GoTo outofz
End If
Next zz
End If

If newsockka = 1 Then
Load Winsock(Winsock.UBound + 1)
newsock = Winsock(Winsock.UBound)
End If

'Winsock(newsock).LocalPort = 10104 + newsock
'Winsock(newsock).RemoteHostIP = listen.RemoteHostIP

ip(newsock) = Winsock(newsock).RemoteHostIP
Winsock(newsock).Accept requestID
MsgBox Winsock(newsock).RemoteHostIP


End Sub

Private Sub Winsock1_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)

End Sub

[Help] Hard Reset Of Form1
Hello. I was wondering if someone could help me here. I programmed my application, and it uses a web control. So, I use my program, and it works, then, when i try to repeat what i just did, it doesnt work to quite the same extent, buttttt, when I close it out, and open it again, it works fine, and so on.

So, i was wondering, How can I simulate The form Closing and opening, without to much time of not having the program open?

Much appreciated, I've tried a lot o.o


Restart Computer?
Hi Everyone! Is there any code in VB that I can use to restart the computer?


Restart Computer
Does any body know the code used to shutdown, need a button on programme where the user can choose to shutdown or restart.

Any help is helpful


Restart Computer
I am trying to restart the user's computer, and I don't know which to use, ExitWindowsEx or Shell (Shutdown.exe -t 0 -r). I tried using:

VB Code:
ExitWindowsEx (EWX_Force And EWX_Reboot, 0&)

but that didn't work.

What should I do?

Thank you,
Sir Loin

Restart This Computer Now!!!
I can i restart a computer within a vb program.

Restart Computer
I am quite new to visual basic, and i need to restart the users computer after my VB program has done it's work.

My restart button is cmdrestart.
I would like it first to logoff, then restart, and if that fails, force restart.
I've found some on google, but none seem to work.


How To Restart Or Turn Off The Computer?

I would like to know how to restart or turn off the computer from the VB application.


How To Restart Or Turn Off The Computer?

I would like to know how to restart or turn off the computer from the VB application.


How To Restart Or Turn Off The Computer?

I would like to know how to restart or turn off the computer from the VB application.


How To Restart Or Turn Off The Computer?

I would like to know how to restart or turn off the computer from the VB application.


How To Restart Computer On WIN95 With WSH And VBS?
WIN95 and IE5.5:

I tried with this:
WshShell.Run ("C:WINDows
undll.exe user32.dll,Exitwindowsex 2 0")
It give me error.
Is there anyway to do it?

One more think I found it that really surprising me:

WshShell.Run ("C:WINdows
undll.exe user.exe,Exitwindowsexec")
If I do this, I can successfully restart the computer, I am just wondering is this good way to call
a private function of system user.exe.

PLease help me out in this, If there is another way to do,
Please tell me.

Shell Function (Restart Computer)
Hi Ppl

i have created a programme as college work but i have a minor problem i need to create a button that when pressed restarts the computer i have tried many types of codes and have even tried just shell(windows directory) but with me being on a network i dont have access to windows directory to know where it is.
I need a piece of code that i can put into my project to log off my computer of a network at the click of a button if you can help me please do as i need this as urgent as possible LAST RESORT !!!!!


What Is It In A Cab File That Makes Your Computer Restart Sometimes?
What is it in a cab file that makes your computer restart sometimes? I'm using P&D wizard and something has recently started making computers downloading cabs containing my activex restart after installation which is a problem.

I can't see what the cause is (OCXs, DLLs etc are the same)

Computer Shutdown / Restart / Logoff
I have an application that seems to interfere with the session ending.

I do cancel the form.closing event temporarily to allow some threads to clean up, and then I exit the application. My application does quit, as well as most other processes, according to Windows Task Manager.

At one time I had a sessionending event handler but it is gone and my computer still will not perform shut/restart/logoff.

Resetting A Com Port Without A Restart
Hey All,

Is there a way to reset a com port from VB6 without restarting the computer? I'm writing a GUI for a mobile robot and the mscomm control hangs up every once in a while in the VB IDE. The darn thing just disappears; if I open the port it tells me it's already open and if I then try to close it it tells me it's already closed. It's both open and closed simultaneously! So far the only way I can clear this problem is restarting the machine. The really wierd thing is that I can, immediately after having this issue, use that same COM1 from any other app I have that is com port capable. Does any one have any experience with this? It's like the IDE just loses track of the port. Here is my code, I'm a noob so feel free to correct me liberally.

My PC: Windows XP with SP2, 2.1Gh, 512mb ram, 60GB HD, one open com port (COM1, DB9)

My Hardware: a working radio link using Linx Technologies SCPA transceivers. I’m using the RTS line to toggle between receive and transmit mode on the radios. The TX and RX lines for the RS-232 are the same. I have them working each way, one rx only and the other tx only and vice versa, but not in transceiver set up, as in each one able to both rx and tx to the other. I'm very confident that these are not the problem.

The Software so far (VB6 w SP6):

Private Sub cmdEnable_Click() ‘enable/disable options on Remote ssTab

If cmdEnable.Caption = "Enable" Then
cmdEnable.Caption = "Disable"
OUTSTRING = "R0" & vbCr
vsbThrottle.Enabled = True
cmdRemote(0).Enabled = True
cmdRemote(1).Enabled = True
cmdRemote(2).Enabled = True
cmdRemote(3).Enabled = True
cmdRemote(4).Enabled = True
txtThrottle.Enabled = True
SSTROBO.TabEnabled(0) = False
SSTROBO.TabEnabled(2) = False
SSTROBO.TabEnabled(3) = False
SSTROBO.TabEnabled(4) = False

ElseIf cmdEnable.Caption = "Disable" Then
cmdEnable.Caption = "Enable"
OUTSTRING = "S0" & vbCr
vsbThrottle.Enabled = False
cmdRemote(0).Enabled = False
cmdRemote(1).Enabled = False
cmdRemote(2).Enabled = False
cmdRemote(3).Enabled = False
cmdRemote(4).Enabled = False
txtThrottle.Enabled = False
SSTROBO.TabEnabled(0) = True
SSTROBO.TabEnabled(2) = True
SSTROBO.TabEnabled(3) = True
SSTROBO.TabEnabled(4) = True
End If

End Sub

Private Sub cmdExit_Click()

Unload Me

End Sub

Private Sub Form_Load()


Dim Otherstring As String
Dim Status As String
Dim temp As String
Dim temp2 As String
Dim temp3 As String
Dim stringin As String

Dim Volts As Double

Dim Throttle As Byte

Open_Port'open the port for use

End Sub

Sub Open_Port()
On Error GoTo errorhandler
MSComm1.PortOpen = True
MSComm1.RTSEnable = True 'true for recieve
lblenable.Caption = "rx"
Exit Sub

If Err.Number = 8005 Then 'port already open
MsgBox Err.Description, vbCritical, "Port Already Open"
Resume Next
ElseIf Err.Number = 8012 Then 'comNoOpen: the device is not open
MsgBox Err.Description, vbCritical, "Device Not Open"
MSComm1.PortOpen = True
ElseIf Err.Number = 8018 Then 'com port not open
MsgBox Err.Description, vbCritical, "Port Not Open"
MSComm1.PortOpen = True
Resume Next
End If

End Sub

Private Sub cmdRemote_Click(index As Integer)

Select Case cmdRemote(index)
Case cmdRemote(0)
OUTSTRING = "F" & CStr(vsbThrottle) & vbCr‘forward and throttle

Case cmdRemote(1)
OUTSTRING = "L" & CStr(vsbThrottle) & vbCr‘left and throttle

Case cmdRemote(2)
OUTSTRING = "R" & CStr(vsbThrottle) & vbCr‘right and throttle

Case cmdRemote(3)
OUTSTRING = "B" & CStr(vsbThrottle) & vbCr‘reverse/back and throttle

Case cmdRemote(4)
OUTSTRING = "S" & CStr(vsbThrottle) & vbCr‘stop and throttle

End Select

txtdebug.Text = "out:" & OUTSTRING

End Sub

Private Sub MSComm1_OnComm()

'this is for receiving

Select Case MSComm1.CommEvent
Case comEvReceive

stringin = MSComm1.Input'define input

temp3 = InStr(stringin, "$") 'find $ position

temp3 = temp3 + 1'find start position, after $

Otherstring = Mid(stringin, temp3, 9)'extract data string, 9 bytes

txtdebug.Text = "in:" & instring & " " & Otherstring

' Get Status

txtRobot.Text = Left(Otherstring, 5)‘shows status

' Get Voltage

temp2 = Mid(Otherstring, 6, 4)

lblVolts.Caption = temp2 & " Volts"‘shows batt voltage

'Send Data

Mscomm1.RTSenable = False‘switch to transmit
Timer1.Interval = 500‘timer delay for radio stabilization
Timer1.Enabled = True

End Select

End Sub

Private Sub SSTROBO_Click(PreviousTab As Integer)

If SSTROBO.Tab = 0 Then‘mode codes
txtOutput.Text = "S00" & vbCr ‘S = standby
ElseIf SSTROBO.Tab = 1 Then
txtOutput.Text = "R00" & vbCr‘R = remote
ElseIf SSTROBO.Tab = 2 Then
txtOutput.Text = "C00" & vbCr‘C = command
ElseIf SSTROBO.Tab = 3 Then
txtOutput.Text = "V00" & vbCr‘V = Sensors
ElseIf SSTROBO.Tab = 4 Then
txtOutput.Text = "B00" & vbCr‘B = behaviours
End If

' txtdebug.Text = "out:" & OUTSTRING

End Sub

Private Sub Timer1_Timer()

OUTSTRING = txtOutput.Text‘get string from textbox

txtdebug.Text = "out:@" & OUTSTRING‘show

MSComm1.Output = "@" & OUTSTRING‘place in out buffer

MSComm1.RTSEnable = True ‘true for receive, default state is receiving

Timer1.Enabled = False‘shut off timer
lblenable.Caption = "rx"

End Sub

Private Sub vsbThrottle_Change()

txtThrottle.Text = vsbThrottle

End Sub

Thanks for any help you all can give.

Can Not Restart Computer Untill VB Program Is Closed
I have what seems like a simple problem,

When i have a vb6 program running on a workstation or a server nt4.0, 2k or xp I have to close the program manually before the system can be rebooted or shut down.

If I select restartor shutdown I get a simple message along the lines of can't quit, If I close the VB Program then I can restart normally


Ho To Reset My Computer By VB? Maybe API Function
Hi All

Is here some way to make this, someone know?

thanks in advance

Computer Reset And Shutdown

I am newbiew, If I want to shutdown or reset from the VB, How could I do that? I guess I have to execute the reset scripts, and shutdown scripts.

Would you please tell me how could I dot that?

thanks in advance


Comm Port
i'm not sure with the terms i used... correct me if i'm wrong.

how can i get the data passed from the port.?

coz i purchased a MODEM pointing to my comm port, then i want to get the data passed on it.? how?

is it possible?

Comm Port !
hello everyone !

i'm doing serial communiction thru comm port in my applcation. in the application startup- form load event i'm setting comm port 1 as default. but there's a prob suppose some computer have comm2 to be set starts giving error messages in the beginning.

how can i chk which current port is available or being used by my hardware and then set it by default in the form load event. tell me how to chk for available port ....

thanks in advance

shruti !

Using COMM Port
How might I communicate with a Sharp El-6790 Organizer using the COMM control? It's plugged into COMM2 and the software that comes with it works fine. I'm just interested in making my own. Any ideas? Thanks

Comm Port
I have a scanner which can read barcodes. It is connected to my comm port 1. How do i get it to display on a text box or label what it has read? Please HELP!

Comm Port
This Is Sort Of Complicated, Maybe someone can help

Basically what i need to do is trigger 5 diffrent motors through a comm port.


is there a way to know which port the modem is located at during run time?

Comm Port
During a (fax)-session, while the commport is in use, I will stop my program. How can I notice that the comm port is in use or not in use ?


Comm Port
I am attempting to write a small program to receive data from a custom radio (modem). The radio uses CST and RTS pins to control transmittion. I tried to use the MSComm1.Handshaking = 0 since the data is only one byte and I dont have to be conserned with overflowing. The radio does not receive when I have it plugged into serial port but starts receiveing when I dissconnect. I asume its the RTS pin on the serial port that is preventing data flow.


VB.6 User, Since 2002
Next Generation Lighting Controls

Comm Port
Hi there.

I'm working on an application that I need to solicit a scale in order for it to send a weight. The scale is hooked to the comm port and I understand the commands that need to be in the program as I have accomplished that before. The catch on this project is that they now have switch to a different scale manufacturer which means a different solicit. This scale manf. wants a Ctrl S. How do I format that command in the .output command? I thought I sent "^S" but it is not responding to it.

Thanks for helping me on this.


Comm Port
How to write data (like Dial Number) into "Modem port "?

Comm Port
Hi there,
I am not sure if I am asking this question in the correct section.

I am seeking help for some VB.NET code which I can interact with the Comm Port of the computer.
For example, if I click on a button, how do we send an output to the comm port?

Can somebody help me on this?

THanks A lot..

code for fun, for to code

how can i read incomming signals from a commport??????
And send them back, by which pins does it all go?????

Comm Port
how can i connect to a comm port with VB??? And with which "plugs" can i send a signal into the computer???
How much Volt goes in and out???
Please help me out!!!!!!

Comm Port
How can i connect to a comm port, and use it to control sommething, a device (that is connected to the comm port).

How Do You Refresh/reset Computer Registries?
Can someone tell me why when I rename a file using the “Name” command that some of the filenames are not getting recorded properly within the computers internal memory.

Meaning that I change/name the filename a few times but only the first naming seems to be recorded in computer history but Explorer has the correct one.


What needs to be refreshed/reset/cleaned? Any ideas...

Thanks in Advance.


How Can I Make The Program Reset The Computer?
How can I make a message box popup asking the user if they want to restart the machine after the program has been exited, and if they click yes, it will actually restart the machine?

Thnx in advance.

Using Com Or Parallel Port To Set/Reset A Bit
I have a circuit that will take the parallel port data line and trigger a relay.

I just don't know how to set and reset individual bits on the parallel port.

Can someone give me an example on how to set or reset one or more of the the data lines on the parallel port. (At this point, I only need one line.)

The end result would be something like

For x= 1 to NumOfIterations
Call ParrallelPortBit("SET")
Call ParrallelPortBit("RESET")
Next x


Comm Port List
I'm looking for a way to list the available comm ports on a system. Just the serial ports (including any usb-serial devices). Like they are listed in the Device Manager in WinXP. Example:

Commincations Port (Com1)
Commincations Port (Com2)
Proflic USB-to-Serial Comm Port (Com4)


Varying The Comm Port

is there a way to access numerous comm ports using only one MSComm Control?
I need to identify the comm port tat a specific device is using and i hv several of such similar devices that is connected. Thus i wish to know which device is using which comm port.
Each device can be set to send in a certain data so i can identify the device using the data send in. I thought of scanning each comm port using the for loop ( 1 to 16 ) and compare wif the default data to identify the devices.
However, I cannot insert in the loop to make the next device send in the data without changing the comm port manually in the program.
I hv use the On_Comm event and two timer(one to request for data and another to request data after time out) to help retrieve the data.
Also, is there a command to resume or carry on the program because if the port is use by other devices, it will juz keep reading the data (though no data is being receive- I hv written to keep requesting for data if no data is receive.)
Sorry for the long qn. Do really hope someone can advise me on this issue.
Thanks a lot!

Open Comm Port
Hallo hi...

I'm facing a problem to open comm port by using 'mscomm control'.
I'm using the default setting in mscomm properties.

When I tried to open port then error message ' invalid port number'

Private Sub Form_Load()

MsgBox MSComm1.CommPort
MsgBox MSComm1.Settings

If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True ' this line gerenate error message
End If

End Sub

please help...

Comm Port Monitor
Here at work, I have the task of figuring out why a particular modem has a high connection failure rate.

There are several pieces that I need to see what's going on "under the hood" from the modem's point of view.

I've just finished rolling my own terminal emulator using the mscomm control.
I need it to allow my vb program to communicate with the local modem via 'AT' interogation commands.
(now here's where I need some help):
The next thing I want to do is to monitor the activity on the comm port that connects to the modem. I need to see the ascii traffic to and from the modem.

I'm thinking winsock but is it udp or tcp?
Overall I'm confused. Before I go down a rat hole, I just need a jump start. I'm not looking for you to write my program for me.

Just to point me in the right direction.

How To Detect The Comm Port?
I got problem about comm port programming, i will not able to detect if my device is currently connected or if my program was able to connect to the device.

can you help me about my problem? I really don't know how to detect a certain device in a comm port.

Calling My Comm-port
Hi, I would like to make a event code for setting on/off a relay with my comm port. I know that i can use mscomm. But if i want to turn on/off a relay or motor with a commandbutton, how should i program it? What pins do i need on my serial port? How can i connect the relay/motor with my port? Is there somebody how have's documentation about the signals that you have on the different pins of the serial/parrallel ports?

Comm Port Trouble
We have a vb6 program in windows 98 operating system that calls 2
DLL's to control a comm port. The one that we wrote in "C" works fine,
expects the comm port to be closed. The controller card company's dll
supposedly opens the comm port in a "shared" mode, which is suppose to
us open the comm port in our own dll with no problems. This doesn't
correctly cause when our dll tries to open the comm port, it is already
open. Is there a way that we can close the comm port from vb? Once we
close the executable program and restart the program and only call our
it works fine until we call their dll again. Can we unload their dll
we finish using the functions in their dll that we need and if so do you
have an example of doing that in VB? Please HHEEELLLLPPPPPP!!!!!!
Thank you for any assistance you can give me in advance.


Gary Curry
Irwin Research & Development
Phone: (509) 248-0194 Ext. 277

Talk To Comm Port
How i want to send a signal to Comm port no 3 if any condition occur in my system..i want to control a gate in cassete conveyor..the gate will connect using comm port 3..then if error occur in mysytem..the gate is will not open..
how to send a signal?
what kind is better signal to send? (0/1, TRUE/FALSE OR OTHERS)

Connecting To Comm Port Via VB6.
I am developing an application that requires signals to be send through the comm port to a microcontroller.I am using VB6 on WindowsXp SP2.I need to know how can I communicate with the Comm Ports using VB6?

Copyright © 2005-08, All rights reserved