I’m a beginner with Visual Basic.
My final faculty project (assembly hardware and software) consists of driving microcontroller from PC.
I have choused visual basic 2005 express edition to make graphic interface (supervising controlling and data acquisition )Argument:
I ‘m using serial COM port for connection between devices.
I my see lateral (ascii) on Hyper terminal; I have programmed my
microcontroler to send me that data.
And at first I would like to see number sent from microcontroller in TextBox tool.
I have added serialport from toolbox to Form1 windov. And I see that settings can be made in propreties windov.
Now in the principle I have to get data variable and send it in textbox.
Where is that variable
I aplay for a help.
Thank you
This is my latest work:
(The meaning way am’ I sending code without concrete reason is that I would like to shove my devotion to this community and serious intention to put energy in this work).
Public Class Form1
Private Sub Button1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim mysum As New sum()
Dim
result As Integer
result = mysum.addTwoNumbers(0, 0)
TextBox3.Text = (result)
'MessageBox.Show(result)
End Sub
End Class
Public Class sum
Public Function addTwoNumbers(ByVal
firestNumber As Integer,
ByVal secondNumber As
Integer) As Integer
firestNumber = Form1.TextBox1.Text
secondNumber = Form1.TextBox2.Text
Return firestNumber + secondNumber
End Function
End Class

com and microcontroler
Adema123
Thanks
I have two classes: form1 and sum.
In the comments I have explained the way of functionality (hove it’s working) of the routine :
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'here i make conection betwen classes
Dim mysum As New sum()
' and i'm puting value in result variable from function addTwoNumbers
' in sum class
Dim result As Integer
result = mysum.addTwoNumbers(0, 0)
'so TextBox3 can Show result
TextBox3.Text = (result)
End Sub
End Class
Thanks to Shakalama.
Problem:
… I can’t figure out what is the way to see in textbox data from com port.
I have dragged and dropped serialport to my form (and controlled the settings) from toolbox and in property window I have kicked on events to create data received event in form window.
Next questions still remains:
PortName property
IsOpen property
Read Method
Write Method
Many days am on the net and I haven’t got (from many examples) what at least must be done to see
data from serial port.
I really do need help because alone can’t get any were.
Good work an much of happiness
Ran Mouri
man b4 you learn to run you have to learn walking, i'm still learning myself for about 3 months now and i didn't even take a look to serialports
serialports are used to send and recieve data, so i have to learn how to manipulate the data first then i'll think later about how to send it, in programming cut and past will not work, every thing will conflict each other because there is no consistency between them if you give an idea to 2 programmers every one will achieve it, but the programs are internaly will be dramatically different
to find a code is good but you have to know how does it work, to be able to manipulate it to fit your need s
believe me its not hard to learn it, just remember good work always need time
hope this helps
Russ Dev
this code will not work like that , because you sum class doesn't see the text box in your form, move add twonumbers method to your form and it will work but remove "form1." from it.
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnvs05/html/vb05legacyhardware.asp
hope this helps
CaiCheng
The receiver in MaxiCOM always show the received bytes as hexadecimal numbers, so the program does what it is told to do (C = 43H). Because the numbers are always hex, no hex specifier (&H etc.) is used. This makes it easier to read the received bytes.
If you want to convert the received bytes to a String of Char, it is very easy to do by means of Chr(ByteToConvert). The receiver already contains this conversion in the last statements, so if you want the receiver routine to write ASCII characters instead of hex, just remove the hex conversion in the Else part of the "If COMPort.BreakState Then" statement as shown below:
If COMPort.BreakState Then
' The break part
Else
RXArray(I) = RXByte
I = I + 1
End If
Best regards
Innovatic
Carsten Kanstrup
Raj127799
Now all files has been added. I have tested the download and it works.
Just download MaxiCOM.zip. Unzip it and doubleclick on MaxiCOM.vbproj. This open the project. No files are shown, but if you press the debug button you will see that it works.
To see the source files is a little tricky. You probably need to go into Solution Explorer (View menu) and press the [Show All Files] button (the middle one). Then you must select Form1.vb. Now two more buttons turns op - one for displaying Form1.vb (code) and one for Form1.Designer.vb. Press the one for Form1.vb and you should be able to see the source code - I hope. If not, play a little with the buttons.
Good luck.
Innovatic
Carsten Kanstrup
Fatih Boy
I use it (two classes) only because of practice .
I have made a temperature regulated system application with microcontroller.
And I started with zero knowledge in that field like I’m starting here now.
I’ll tray to explain my filozophy of learning VB. I have a problem. And I have to resolve it with Visual Basic.
I need to make graphic interface (system controlling and data acquisition).
So at first I have to make any connection between PC ( window made by VB)
and microcontroller with serial port.
So I’m concentrated directly on this problem. And everywhere a look I see long versions of code with,…, I don’t know what. Or there are only short pieces of code that when I pot them together I get many errors.
I think now I made me understandable: it is only that I can’t find I way to learn thru my work. I wont to build something what has purpose.
Thank you
Per Dunberg
i don't know why do you want to isolate this operation in new class why don't you use the same class
it will be something like this
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim result As Integer = Me.AddTwoNumbers(0, 1)
TextBox3.Text = result
End Sub Private Function AddTwoNumbers(ByVal n1 As String, ByVal n2 As String) As Integer Me.TextBox1.Text = n1
Me.TextBox2.Text = n2
Return Integer.Parse(n1) + Integer.Parse(n2)
End Function
i hope if you start with the basics first then you can do something with vb you can find a helpers in this thread http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=212558&SiteID=1
hope this helps
Cabreo
I believe you .
Maybe someone knows the answer for this question (comment in code)
Public Class Form1
'here when i clik on the button message box appears (click).
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show("ckick")
End Sub
'so way here when data apears on com message box doesn't appears
' serialport properties setings ( 19200, 8, none,1)
Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
MessageBox.Show("data on com")
End Sub
End Class
Sumit2006
I don't know anything about creating graphs. Ask the forum in a new thread.
Good luck with the project. I am glad I got you started. I know how frustrating it is when you cannot proceed with a project before you have made a Windows application, but just feel that everything is overwhelming, nobody is able to help you and you just don't know where to start.
ndPriya Anand
You may find a small program for serial communication including the Visual Basic .NET source code in the knowledgebase on our homepage.
http://www.innovatic.dk/knowledg/SerialCOM/SerialCOM.htm
Good luck with the programming.
Innovatic
Carsten Kanstrup
fsoehnge
Thanks to Carsten Kanstrup
I my say that it is much easier now.
Normally I open my projects from start page in recent projects window and I have found that also can be done from .vbproj and .sln file. Trying to open yours .vbproj file I ‘m getting next errors:
Warning 1 The custom tool 'MyApplicationCodeGenerator' failed while processing the file 'My Project\Application.myapp'.
Warning 2 The custom tool 'VbMyResourcesResXFileCodeGenerator' failed while processing the file 'My Project\Resources.resx'.
Warning 3 The custom tool 'SettingsSingleFileGenerator' failed while processing the file 'My Project\Settings.settings'.
Error 4 Unable to open module file 'D:\ ola\diploma\diploma2\viual basic\Carsten Kanstrup\My Project\Resources.Designer.vb': The system cannot find the file specified. D:\ ola\diploma\diploma2\viual basic\Carsten Kanstrup\My Project\Resources.Designer.vb 1 1 MaxiCOM
Error 5 Unable to open module file 'D:\ ola\diploma\diploma2\viual basic\Carsten Kanstrup\My Project\AssemblyInfo.vb': The system cannot find the file specified. D:\ ola\diploma\diploma2\viual basic\Carsten Kanstrup\My Project\AssemblyInfo.vb 1 1 MaxiCOM
Error 6 Unable to open module file 'D:\ ola\diploma\diploma2\viual basic\Carsten Kanstrup\My Project\Application.Designer.vb': The system cannot find the file specified. D:\ ola\diploma\diploma2\viual basic\Carsten Kanstrup\My Project\Application.Designer.vb 1 1 MaxiCOM
Error 7 Unable to open module file 'D:\ ola\diploma\diploma2\viual basic\Carsten Kanstrup\My Project\Settings.Designer.vb': The system cannot find the file specified. D:\ ola\diploma\diploma2\viual basic\Carsten Kanstrup\My Project\Settings.Designer.vb 1 1 MaxiCOM
Working, I have found next way to resolve the problem:
then I copied also next peace of code from Form.designer.vb and I marked it like comments (to not interfere with code) :
' Me.Received = New System.Windows.Forms.TextBox
'Me.SendButton = New System.Windows.Forms.Button
'Me.TransmittedLabel = New System.Windows.Forms.Label
'Me.ReceivedLabel = New System.Windows.Forms.Label
'Me.BaudRateBox = New System.Windows.Forms.ComboBox
'Me.BaudRateLabel = New System.Windows.Forms.Label
'Me.COMPortsBox = New System.Windows.Forms.ComboBox
'Me.ComPortLabel = New System.Windows.Forms.Label
'Me.ClearButton = New System.Windows.Forms.Button
'Me.BreakButton = New System.Windows.Forms.Button
and I used it like component list. And I deleted Button control which I have made on the beginning (for getting to the code window).
3.Then I opened Form window and dragged and dropped commands from toolbox
into the form window using looking pasted (point 2.) component list like reference.
4.at last I changed names of components in components properties window ;
( got from component list;…, and they (names) were also underlined with blue in code to)
And it’s work.
I know this problem can be resolved in much easier way , now that I have all files.
But maybe some well get use from this if he have only form.vb and form.designer.vb file.
Ok.
Now I me se data from microcontroller. I sending “C” letrer but I recive decimal number 43. Yes I know it is heksadecimal namber in Ascii code for “C”.
I think is not appropriate to apply help because I haven’t studied this problem yet
but maybe someone have practice answer.
Good work and much happines
camus
Yes, I have now my data as string of char.
Thank you.
I’m in situation when I have to make plane have to continue with my project.
Because now things are becoming larger.
To get the idea in which way to continue I need to know some basic things
About creating a graph.
Where can I find some theory abut it
Guillermo D. Polonsky
I have added file Form1.VB and Form1[designer]. VB in solution explorer by double clicking on my project name selecting existing item.
I resolved one error after changing from default Form1 startup form to new added form
but next 2 errors still remains:
Error 1 Identifier expected.
Error 2 Attribute specifier is not a complete statement. Use a line continuation to apply the attribute to the following statement.
Booth errors (marked red ) are in next line of code (in component list (Form1.designer.vb))
<System.Diagnostics.DebuggerStepThrough()>_
I very greatful to Carsten Karstrup for help.
I think, in this case, if this two errors will be resolved and anything else wont get wrong
that I will have that I was looking for.
So I’ll work on code and learning making modifications to the point I wish to.
I wish you I beautiful and magic first day of spring with much of happiness.
aZed
It may be so that the two files Form1.vb and Form1.Designer.vb is not enough. More files may be needed. I will check this up and add any missing files.
Best regards
Innovatic
Carsten Kanstrup