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

Help (communicate With Controller That Use Modbus-rtu)



01 03 01 00 00 01 85 F6

Private Sub Command1_Click()


mscomm1.PortOpen = True
MSComm1.Output = Chr(&H0) & Chr(&H1) & Chr(&H0) & Chr(&H3) & Chr(&H0) & Chr(&H1) & Chr(&H0) & Chr(&H0) & Chr(&H0) & Chr(&H0) & Chr(&H0) & Chr(&H1) & Chr(&H85) & Chr(&HF6)
TimeDelay (500)
Label2.Caption = MSComm1.Input
Debug.Print "MSCOMM1.InBufferCount" & N & "="; MSComm1.InBufferCount
Debug.Print "MSCOMM1.INPUT" & N & "="; MSComm1.Input

MSComm1.PortOpen = False

End Sub

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Modbus ?.
I am trying to create a simple app that will poll data from an HP machine. It is a very old legacy machine that runs the inputs/outputs for our plating system. Last year they paid someone to setup a record dump of 53 fields from the HP to a local pc. They never used the data and now they want to. Whoever set this up used Wonderware and Modbus? I am not exactly sure what is happening but it seems that the modbus server is polling some HP addresses and then passing them to wonderware. Wonderware is then putting them on text boxes on a form and dumping the text box data to Access97 via an ODBC driver? This probably doesn't make any sense but I can't believe that it requires all of the third party software liscences for Wonderware etc to do something this simple. Any response would be apprecitated.

Modicon Modbus Plus
I am hoping someone can help me with PLC communications using Modicon PLC's.
I need some help with connecting a Visual Basic program to a Modbus + network to read values. I have a copy of ProWorx NXT & ProWorx 32 on my computer and have a modbus+ card installed to the network. I have tried to add a component prwocomm.ocx to my VB project but have no documentation or reference’s to show me how to set it up to communicate. Can anyone give me any advice or direction on how I can get VB to connect and read from Modbus+?

Thanks in advance.

MODBUS Protocol
Does anyone develop this protocol under VB6 or vb5?
Or exist a control to communicate with this protocol?


Modbus Problem

Thanks for reading. Iam using Modbus for connecting to a Server with a modem, dialing and getting some values from the server. Everything works fine, but in some machines, Modbus server is failing to register so the dialer does'nt work.
I even tried registering it manually

MBServer.exe /RegServer
But it fails to register and reports some access violation in Ole32.dll. This happens only in one WindowsNT(I have SP5) and in another Windows98 machine. Rest all machines it works fine.

Any idea about this??


ModBus Protocol
Hello VBGuys,
I'm working with an equipament that has an RS232 serial interface with the RTU ModBus protocol. I'm using the MSComm component to talk with the equipament. I need to read something of the equipament but I can't. The read string only contain ????. I can write on the equipament, but not read the answear back.
To write, I send the correctly string with the mscomm.output property.
To read something of the equipament I use the mscomm.input property.
I don't Know if the delay between read each caracter of the answer is wrong.
If someone worked with this protocol or know the answer, please tell me.

Edited by - BarrosAS on 12/10/2003 9:43:07 AM

ModBus Protocol
Has anyone had experience with communicating to devices using the ModBus/TCP protocol?
I am wanting to create my own driver to use with VB to communicate using this protocol.
If anyone has done any of this let me know thanks!!!

If anyone is interested you can find info on this protocol at:

Software Engineer

Implementation Of MODBUS RTU Slave In VB 6.0

We are doing the project on PLC-DCS interfacing. The main problem in this project is the protocol mismatch. We are using PLC which uses proprietary protocol for serial communication and the DCS we are using is Delta-V which uses MODBUS protocol. So we can't connect them directly. We have to build a protocol converter for MODBUS-proprietary protocol communication. For thi reason we are using computer in between as protocol converter.Uptil now we are able to receive the data on PC from PLC by sending read command through COM1 port of PC.

We have programmed it in VB6.0. Now the remaining part is Modbus slave implementation through COM2 port which we will connect to DCS.

DCS acts as Modbus master and send queries continuously. We want to create holding registers in computer which is MODBUS slave in this communication. The data from PLC should be written at these holding registers.And DCS will read these holding registers by sending Function code 03 to the slave(which we want to implement).

Required holding register addresses are: R40000 to R40100.

The communication parameters are

Baud rate : 9600

Data bits : 8

Parity : none

Stop bit : 1

We will be very much thankful if anybody can help us.

Our contacts:



Thank you,

Vijay and Swapnil

How Do I Add A ADO Controller?
How do I add an ADO Controller to my coding? The code is attached

Emulate A Controller
I have a vb app that talks (through serial) to a controller with a motorola microprocessor and simple rom configuration. What I need is to emulate the controller somehow.

A few thoughts that after searching through a bunch of threads here and google:

1. Is there any way to do an internal loopback from the serial to avoid any cables needed? (I do not believe so)

2. If a usb to serial connection is available, I could write a new app that emmulates and have it talk through the USB to the serial and into the current app. (Seems possible)

3. If 2 is possible, can a controller be emulated simply (or not so simply) internally through a program.

Any thoughts would be appreciated.

Shapes Over Controller
Im making a small game and need to have shapes OVER pictureboxes in this case, which for some reason doenst work, Ive used vb some time though not really shapes but still havent noticed they always stay under other controllers. tryed bring to front and ZOrder so those things dont work.
so basicly, is there a way to have a shape over a picturebox? transparency inside the shape isnt necesary though it would be nice. (without actually putting the shape inside the picturebox)


24-Line I/O Controller Kit
i just got one of the above and need code on how to make it work. If you dont know what it is it is a little box that connects to your computer and allows you through VB to controll outside devices such as lights, motion cencers, fountains or anything. Can you please let me know where to get code for this

Data Controller In VB 5
I'm working on an application to do the administration on my work. In my form I wanted to use different tables of a database called 'db1.mdb'.
I connected the data control to this database and left the Recordset attribute empty. In my code I wrote the following part:

Data1.RecordSource = "PC"
Label1.DataField = "Type"
Label2.DataField = "ID"
Label3.DataField = "IP"

This action is performed when a button is clicked. In another function the Data1.Recordsource changes to 'Printers' as well as datafields of the labels.

The result of this is that there's no error, but no records as well!

Who can help?

Compiler Controller
Hi OnErrOr,
How do I get hold of the Free Compiler Controller for VB5/6.
I know it is possible to create stdCall Dll's using VB6 because I have done it, but it won't let me create them with forms. The Compiler Controller may let me.
Thanks in advance.

Compiler Controller
Banjo, OnErr0r, Rockoon

A couple of notes about that CC enquiry (

1. Is open discussion of CC's a sensitive issue? I wasn't sure why the guy's question got short shrift, and that's the only reason I could think of ...

2. Making VB6 dll's without a CC - I've been able to do that ever since I bought Desaware SpyWorks 4 years ago - not that I use it any more, but it served a useful purpose as an entry point into that area - I'm not sure why that was challenged?

3. On a more interesting, and thread-related, issue, have you ever seen a VB6 EXE with an Export table? According to MSDN, EXE's can have them, any PE can, and I have a need for one, because it's the only way I can think of to get around the "name decoration" problem - cf my unanswered thread in Misc Languages (btw: can any of you confirm my fear that there really is is no ALIAS service in the VB6 LINK.EXE to resolve name conflicts like that?)

Speaking of VB's LINK.EXE, there is a simple, but fatal bug, that may have prevented others from successfully completing this experiment - you just do a normal compile and link, and add a DEF file to the LINK step.

LINK is happy, a PE viewer says it's a Win32 executable, it has an export table (which it reads not from the PE file, but via memory, after MapAndLoad'ing the PE)

Ah, but try to run it, and Windows will sternly rebuke you ("That executable looks dodgy, fella!" )

Hmmm, what MapAndLoad had no problem with, LoadImage certainly did!

4. Finally, re "sharing" Forms objects, I've got this tool that lets you share them in a bizarre way - it's a VB DLL that, when called from, or injected into, any VB6 exe, can get a valid reference to the host application's Global object, hence Forms, Controls, etc ....


Application Controller

This is a follow on to my previous post (Windows Service). How do i use another program (e.g. with a form) that i can change variables, reboot, pause, etc. of the service.

An example of this is MySQL. The program runs as a service. Then there are other programs which let you control it (e.g. Client, Stop, Start, Admin)

Any help would be awesome, thanks guys.

Volume Controller
What is the techniques behind creating a graphical volume controller.
I am not referring to the mixer (Sound Card) VB codes.

I want to know how the graphical controller has been created using graphics to move up and down (Min to Max) in a predefined line.

If your not still understand my question follow this please :
Open Microsoft windows media player 8 or higher > Select Skin chooser > Select skin named “Canvas” or “Bluesky”. Now just increase the volume using that graphical controller.

Ok? My question is all about that controller’s behavior technique.

Get Domain Controller Name

I think this is an easy question, but maybe not.

How do I get the name of the Domain Controller for the system that a VB6 application is running on?

Is there a command for exactly this?


- Jake

Volume Controller
I want to increase or decrease the speaker volume through VB. I should also be able to show the new volume level if the user changes the level through volume control available in windows. Does anyone know any link form where I can get the souce code or any activeX control. Thanks.

Motor Controller
I am new to Visual Basic, and I am trying to figure out how to interface this stepper motor controller using VB. I have the controller working using Hyperterminal, but my boss wants me to use VB.

I really do not know where to get started on this project. Please help.

This is what I have been playing with:

Private Sub Command1_Click()
GoToLocation(ByVal lX As Long, ByVal lY As Long)
End Sub

Private Sub Command2_Click()
GoToMarkedLocation(ByRef strWhichMotor As String)
End Sub

Private Sub Command3_Click()
ResetBoard(ByVal sMicrostepSize As Integer)
End Sub

Private Sub Command4_Click()
Slew(ByRef strWhichMotor As String, ByVal lDirection As Long)
End Sub

Private Sub Command5_Click()
StopMotors(ByVal fWaitForStopped As Boolean)
End Sub

Private Sub Form_Load()

End Sub

Private Sub MSComm1_OnComm()
' Buffer to hold input string
Dim Instring As String

Command1.Enabled = False
' Use COM1.
MSComm1.CommPort = 1
' 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.Settings = "9600,N,8,1"
' Tell the control to read entire buffer when Input
' is used.
MSComm1.InputLen = 0
' Open the port.
MSComm1.PortOpen = True
' Send the attention command to the modem.
MSComm1.Output = Text2.Text & ch4r$(13) ' Ensure that
' the modem responds with "OK".
' Wait for data to come back to the serial port.
Buffer$ = Buffer$ & MSComm1.Input
Loop Until InStr(Buffer$, "ok" & vbCrLf)
' Read the "OK" response data in the serial port.

Text1.Text = Buffer$
' Close the serial port.
MSComm1.PortOpen = False
Command1.Enabled = True
End Sub

Basically,I need to be able to do the following things:

-Make the motors go home (X=0,Y=0)
-Slew the motors (+/-)
-Make the motors go to a specific location
-Stop the motors
-Reset the board
-Report the location of the motors

Edited by - TSL1 on 2/2/2007 8:24:12 AM

Infrared Remote Controller
I want to make A Serial Infrared Remote Controller it must be able to
read my old remotes so I know the code and sent to my tv, vcr, dvd,
ps2, and 6.1 sound sound here one web site I found but it is too hard
to under stand the parts

If you hae another way to do it pleze tell me.

VB And Controller Area Network (CAN)
Hi everyone,
i want to be able to send and recieve CAN messages to and from a VB app developed in Visual Studio,

Remote Controller On IRDA
Hi there,

I cant get my notebook responding on signals I send with a remote controller. I use the build-in IRDA port of the notebook. My OS is windows XP.
I used IrCOMM2k to make a virtual comm port, but because I don't know anything about MSCOMM of Winsock, I cant get the data I'm sending.
Does anyone know how I can make a VB program that can intercept the signals I'm sending? I thought something like this:

Private Sub MSComm1_OnComm()
MSComm1.CommPort = 3
List1.AddItem (MSComm1.Input)
End Sub

But that's not working.



Stepper Motor Controller
how to control the stepper motor using Visual Basic code

Controller Of Minimize Button
How to, when click the minimize button from a form do something before minimize the form?
I have try the following code but the form minimized and later show the message box. I want to show the message box when click the minimize button before minimize the form.
I hope for help. Thanks

Private Sub Form_Resize()
If WindowState = vbMinimized Then
MsgBox "XX"
End If
End Sub

How Do I Make A Volume Controller?
that interacts with the windows volume controller?
if i move it up the the volume of the windows volume controller also goes up?

What API call do i make?

Internet Controller Problem
Hi there:
I'd build a web browser. I'd successfully disable pop-up page during surfing, but there are still one unsolve problem. Some of the web page will only display the pop-up page after I close the browser. It create a problem where when I close the browser I already set the object I create to Nothing, so I can not catch this action. ANy suggestion on what I shall do? Thanks


Joystick/controller Event?
i'm attempting to learn event driven programming... so bear with me. I am attempting to learn by doing with the temporary goal of a small app that mimics the display of the "game controller" properties page in the control panel (i.e. show graphic when button is pressed or joystick is moved in a direction).

towards that goal I found the API function joyGetPos.

now I'm wondering... how do I listen for events on the joystick/controller, and how is the state of the controller returned (is the structure passed by reference and altered by the function?)


edit: just found the joyGetPosEx ... this may be more what I need... questions still stand though

Datagrid Or Adodc-controller

subscript out of range error comes when assign recordset fields are not match with data grid columns.check the query u r passing to data grid.

How Do You Find Out If A PC Is A Domain Controller?
I have a program that feeds servers info. I need skipover code that will make sure any domain controllers are skiped. Thanks

Domain Controller (Mr Dwyer...)
Hello again all, great to be back.

I've just spent the whole morning trying to get this bleedin' NetGetDCName() API call to work and all I can manage is error 53 which, as far as I can tell, means "Could not find domain controller for this domain," which is odd because I happen to KNOW that this domain and all the controllers exist and are operational.

Has anyone (Paul Dwyer I've seen your name on a similar post...) ever got this call to work? I'm not even that desperate to use this call, anything that'll simply return me a domain controller that I can use to validate a username/password is fine.

Please help I'm going bonkers

Cheers all,


MS DataGrid ActiveX Controller??

I want to use the MS DataGrid without using the ADO controller.
If I use the ADO it's only to connect the DataGrid property DataSource and then I'm connected.

BUT, witch property will I use if the call on the connection and recordset code look like this

Set adoConnection = New ADODB.Connection
adoConnection.Open m_def_ConnectionString
Set adoRS = New ADODB.Recordset
adoRS.Open "Plan", adoConnection, adOpenDynamic, adLockOptimistic

I would be very grateful if someone could help me!


How To Add A Image To Ado Data Controller?
can any one tell me how to add a picture to ADO Database Controller...
Cause i am a new user of ADo controller and i don't know how to add a picture to it...

IrDA With My TV Remote Controller
Is it possible to control any Win32 Aplication with my TV Remote Controller through IrDA adapter connected to my motherboard?

ADODC Controller And UDL Files
I'm using an UDL file to define the connection string to an SQL server database. This is done by just specifying the udl file name in the connection property of the ADODC controller. This works fine in winnt but not in winxp. As the installation directory should be variable (C-drive or antoher) i can't include the full path to the location of the udl files, so i just put the name of the udl file alone in the connection information.

Windows XP seems to look for the udl files in the following directory c:program filescommon files/system/ole db/data links. I tried to copy the udl files there but that didn't work either. When i start the program i always get the error [ADODC]:Unkonwn error[ADODC]. When i go to the programming environment in VB6 and i open the ADODC controller and browse to the location of the file it includes the full path. Clicking apply, removing the path before the udl filename and then ckicking apply again solves the problem. the next time i start vb6 again and try to run the project again i get the same problem. In short, you have to point to the udl file once and then it seems to be registered somewhere for the duration of the VB6 session.

I also tried to look for the location of the udl file on all drives and then adding this connection string to the ADODC controller at run time. This does not work either as the order of building components at run time is not in a fixed order. In this way a timer which starts a refresh of the ADODC recordset is already operational before the connection string was passed to the controller. I thought this was due to the fact that i included it in the load procedure. Moving it to the initialize part did not solve the problem either

 hope someone can help me out on this one. I'm looking for a solution for 2 months now.

thanks in advance for any help you can supply me



Determine The Domain Controller
How can I get the name of the domain controller I'm loggin on to? We are using an environment with 2 domain controllers, and in order to get the mapping right, I need to find out which domain controller I'm using.
Any help in welcome.

Tom Cannaerts

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

Can I Compile Java In Active X Controller,,..?
i;m doign a system where i need VB6 to communicat with java on a network sending string to each other...a friend of mine said i fi i'm able to comipile java in active x control then its possible......can anyone help?

Using A Game Controller As The Input Device
I recently installed a new Microsoft Sidewinder USB game controller on my PC for use in a few games I would like to play, but without only the keyboard seems to be supported (Splinter Cell, in this case).

I was just wondering if anyone could tell me as to where I could get some info on taking input from a game controller. Also, if I were to write a simple program that captures that input and generates a corresponding keypress of a keyboard key, would this work with the game running, or is there no possible way to manipulate this using an application running in the background?

How To Make Stepper Motor Controller Using Vb
what hardware do i have to build to be able to control the activity of the stepper motor using vb6.. i was thinking how to give a signal or pulse to activate the relay to give power to stepper motor(5-12volts) newbie about this thing.."this waht i think..

1.vb6 will give a pulse or signal through printer port

2.what components or hardware will convert the signal to activate the relay?

3. then after the signal was converted, it will trigger the relay so that the motor will receive a a voltage coming from relay..

my problem is what hardware do i need for the signal coming from the parallel port to convert to be able to activate the relay.

i hope you undersatand and for your kind consideration.

Any Good Parallel Port Controller
Do you guys know any good parallel port controller. I making a stepper motor controller. And I have io.dll. I works at home on my computer but It does not work in any other computer to if you guys know any othe dll which works with most of the computer then please tell me

How To Determine If A System Is A Domain Controller
How to determine if a system is a domain controller ...?

Treeview Controller And Checkboxes Only For The Parents???
I've searched the forum but I couldn't find something about this:

Is it possible to add only checkboxes to the parents of the treeview? And how can it been done if it's possible?
I know you can select the propertie "checkboxes" of a treeview but I only need checkboxes for the parents.

With kind regards,
A noob who's learning some VB

Visual Basic Game Controller Driver
Is it possible to make a controller driver with VB?

Go to (in Windows) Start -> Settings -> Control Panel, then Gaming Options.

Complier Controller – Using Stdcall And Generating Listing In VC++
I’m reading Compiler Controller documentation and I got stuck at the part I have to change the calling method (is that the name?) to stdcall and generate lst file (assembly listing – right?).
I checked the ProjectSetting but such options are nowhere to be found.
Anyone could help ?

Sending A POST Request From VB6.0 To Spring Controller
Hi All,
I need to POST a request which will actually call a spring controller (file upload )written in java.How do i do it?
Please help me.Response Will be Appreciated.
Thank you.

School Lighting Controller Thingy Reopened
Hi everyone,
I have reopend this because it seems to have dissapeared even from my history. Any way we were working on a way to control, stage lighting through a computer, reme,ber that the lights are analogue and not digital so we cant use dmx controlers.

Manage User And Group On Domain Controller By Using VB...
I have some problem about using VB to manage user and group in Domain Controller.Since I try to use WIN32API
to manage user and group on domain controller,I have never successed because I have no document of API.
One I can do is I can change password by using WIN32API.My problem is anyone know the way how to manage
user and group (Add,Add to group,Change password,Change Group,Delete) by using VB?

Vb Controller Code For Usb Port Convert To Rs232 Communication
Hi friends!
For rs232 communication we use MScom control as controller,so what kind of controller for usb port? i`m using bafo usb to serial converter and install the driver, i check it in device manager under port(com&lpt) indicate as Prolific USB-to-Serial Bridge (Com3).

Common Dialogue Controller Help Need *New: Easy For The Experts&"
I am currently trying to open a database from the common dialogue control, i got this from another thread:

dim strFile as string
comD.Filter = "MS Access Files " & "(*.MDB)|*.MDB|"
comD.FilterIndex = 0
comD.Flags = cdlOFNFileMustExist
comD.Flags = cdlOFNHideReadOnly
'comD.Flags = cdlOFNNoReadOnlyReturn
comD.FileName = ""
strFile = comD.FileName

If strFile <> "" Then
perform some code
no file was selected, you can exit
end if

What i need to know is how to store the filename and how to get it to open the selected filename, also what will i need to put in the properties box where it asks for database name in the "data controller"

Is There A Way Tolet My Vb6 Program To Authenticate/login On A Domain Controller?
Hello all,
I got a question
I have made a program to for certain pc's on my home lan. The problem is that the people that wish to use it need to be logged into the domain, and not all the pc's are a member of that domain (for my own private reasons). Is there a way to let a Vb6 program authenticate/login on a domain controller and if yes, would you mind to tell me how, and what references or components I would need to use for it?

Thanks in Advance all.

Copyright © 2005-08, All rights reserved