|
Write up an article and submit it. Bear in mind that many people would probably not be eager to run an .exe that they don't know. With your article, send in the source code as well.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
|
I’m not a programmer or a formal student, rather I’m a 48 year old that loves to tinker, and has no programming experience per say. What I need is to know where to find VB6 examples of a program similar to what I have described below to teach me how to create my application in VB6. If none of them exist or are readily available, than I need some basics to get me started and figure out how to create my desired program using the basic examples provided with the hardware I’m working with.
I’m attempting to create a program that will allow me to use the data from sensors connected to an interface board (Phidgets 8/8/8) primarily pressure & oxygen sensors, and with the data I receive from the sensors I will use that information to control servos with the same interface based on preset values or ranges automatically. The Phidgets Interface Kit 8/8/8 comes with software examples / basic software interfaces written in VB6 so you can receive data and view sensor input changes which I’m doing now. It also makes available similar modest software to control the servos. My endeavor is to use the software / code examples provided in VB6 to create a more advanced program that will allow me to monitor, record / document, automate and control my device through the servos based on the sensor information.
Below are examples of the general interface code and the servo controller code provided with the hardware.
VB6 examples provided with the hardware:
' Program: InterfaceKit-Controller
' Author: Saul Greenberg
' Date: October, 2001
' Version: 1.0
' Description:
' - Gives a handy generic visual interface to the interface kit.
' - It displays the status of all analog and digital inputs
' and lets you turn on/off the outputs.
' - Its not actually that complex, as most of this just builds
' the visual interface. It is, after all, dealing with 20
' different inputs and outputs!
' - Note that you can adjust the min/max to increase/decrease the
' apparant sensitivity of the sensor (although it may get jittery
' if you stretch it too far)
Option Explicit
Dim WithEvents IFKit As PhidgetInterfaceKit
'''''''''''''''''''''''''''''''''''''''''''
''' User interface
'''''''''''''''''''''''''''''''''''''''''''
Private Sub Form_Load()
Set IFKit = New PhidgetInterfaceKit
IFKit.Open
'If (IFKit.IsAttached = False) Then
' MsgBox "Couldn't Connect to Interface Kit"
' Unload Form1
' End
'End If
End Sub
'Turn individual outputs on or off depending on which Output checkbox was selected
Private Sub chkOutputDigital_Click(Index As Integer)
If chkOutputDigital(Index).Value = 0 Then
IFKit.OutputState(Index) = False
chkOutputDigital(Index).BackColor = &H8000000F
Else
IFKit.OutputState(Index) = True
chkOutputDigital(Index).BackColor = vbRed
End If
End Sub
Private Sub IFKit_OnDetach()
DisplayProperties False
End Sub
Private Sub IFKit_OnAttach()
DisplayProperties True
End Sub
Private Sub IFKit_OnError(ByVal Description As String, ByVal SCODE As Long)
MsgBox "Error " & SCODE & ": " & Description
IFKit.Close
Unload Form1
End
End Sub
Private Sub RatioSelect_Click()
If RatioSelect.Value = 0 Then
IFKit.Ratiometric = False
Else
IFKit.Ratiometric = True
End If
End Sub
'Let the user set the sensitivity of the sensor reporting through a combo box
'i.e., a delta of the given amount must be seen before it will report it
Private Sub sensitivity_Click(Index As Integer)
If sensitivity.Item(Index).Caption = "Medium" Then
sensitivity.Item(Index).Caption = "High"
IFKit.SensorChangeTrigger(Index) = 1
ElseIf sensitivity.Item(Index).Caption = "High" Then
sensitivity.Item(Index).Caption = "Low"
IFKit.SensorChangeTrigger(Index) = 60
ElseIf sensitivity.Item(Index).Caption = "Low" Then
sensitivity.Item(Index).Caption = "Medium"
IFKit.SensorChangeTrigger(Index) = 10
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''
''' Events generated by the Interface Kit
'''''''''''''''''''''''''''''''''''''''''''
'Report the value of the input whenever it changes
Private Sub IFKit_OnInputChange(ByVal Index As Long, ByVal NewState As Boolean)
If (Index >= lblInputDigital.Count) Then Exit Sub
If NewState Then
lblInputDigital(Index).Caption = "On"
Else
lblInputDigital(Index).Caption = "Off"
End If
End Sub
'Report the value of the sensor whenever it changes
Private Sub IFKit_OnSensorChange(ByVal Index As Long, ByVal SensorValue As Long)
If (Index >= sldrAnalog.Count) Then Exit Sub
sldrAnalog(Index).Value = SensorValue
lblAnalog(Index).Caption = SensorValue
End Sub
'''''''''''''''''''''''''''''''''''''''''''
''' Utility routines
'''''''''''''''''''''''''''''''''''''''''''
'Display the current properties of the IFKit in a label
Private Sub DisplayProperties(State As Boolean)
Dim i As Integer
lblProperties.Caption = ""
If State = False Then
Display "Detached"
Exit Sub
End If
Display "DeviceType: " & IFKit.DeviceType
Display "SerialNumber: " & IFKit.SerialNumber
Display "IsAttached: " & IFKit.IsAttached
Display "NumInputs: " & IFKit.NumInputs
Display "NumOutputs: " & IFKit.NumOutputs
Display "NumSensors: " & IFKit.NumSensors
Display ""
Display IFKit.LibraryVersion
End Sub
Private Sub Display(Line As String)
lblProperties.Caption = lblProperties.Caption & Line & vbCrLf
End Sub
Servo Slide Control Examples:
' Program: ServoSlider
' Author: Chester Fitchett
' Date: Feb 25, 2005
' Version: 1.0.2
' Description:
' -This example:
' o lets a user interactively adjust the angle of all motors through a slider
' o displays all the information it can about the PhidgetServo.
' o is somewhat robust about ignoring other Phidget servos that are attached
'
Option Explicit
Dim WithEvents Servo As PhidgetServo
Private Sub Form_Load()
Set Servo = New PhidgetServo
lblMessage.Caption = "Attach a PhidgetServo"
Frame1.Visible = False
sldrRotate.Min = -23
sldrRotate.Max = 231
sldrRotate.TickFrequency = 20
Servo.Open
End Sub
'SERVO ATTACHING
Private Sub Servo_OnAttach()
'Set up the slider
Frame1.Visible = True
sldrRotate.Value = 90
sldrRotate_Scroll 'Will rotate the motors to angle 0
'Show the current Servo information
lblMessage.Caption = "PhidgetServo Attached"
lblNumMotors.Caption = Servo.NumMotors
lblSerialNumber.Caption = Servo.SerialNumber
End Sub
Private Sub Servo_OnDetach()
'Show the current Servo information
lblMessage.Caption = "Attach a PhidgetServo "
lblNumMotors.Caption = ""
lblSerialNumber.Caption = ""
lblAngle.Caption = ""
Frame1.Visible = False
End Sub
Private Sub sldrRotate_Scroll()
Dim Index As Long
For Index = 0 To Servo.NumMotors - 1
Servo.MotorPosition(Index) = sldrRotate.Value
lblAngle.Caption = Servo.MotorPosition(Index)
Next Index
End Sub
|
|
|
|
|
Best to dump VB6 since it is not supported anymore.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Probably the best place to look for examples would be the manufacturers website. I took a quick look at it and they have a forum where you can ask questions. You could try google but many of the examples are probably not going to be usefull if they are not for your particular package since they won't be using the phidgets api.
Speaking as a self taught programmer myself, here would be my advice. I would say that trying to learn by osmosis (looking at code examples) is not the best way, you need to learn a few basic concepts which I will list below. Most of these basic elements will occur in any program regardless of what it does. The thing that differentiates programs is less the basic elements you use but rather how they are combined. I would advise going to the library and getting a vb book or at least looking up these terms on the internet.
1) What are variables and arrays and what is variable scope?
2) What are subs/functions/methods and events? What are arguments/parameters? What is the difference between passing by value and passing by reference?
3) What are conditional statements (ie if then else elseif ect...)
4) What are loops (both for next and do loops)?
5) What do the commands NOT, AND, OR, and XOR mean?
6) How to write mathmatical expressions and how to write strings?
7) What are modules?
Finally you need to learn how to use the program itself, how to drop controls onto a form, and sometimes overlooked how to use the debugging tools (ie breakpoints, stepping through ect...)
There are many other items I could have added but those are definately the most important commands and are central to virtually every program. Once you learn them you should be able to write some simple programs and understand alot of the code and documentation that comes with your kit.
One last thing; although vb6 may be a tad easier to use it is going to be harder to find code examples for it because it was replaced by vb.net some years ago, you might want to consider switching. If you do you can download the express version for free off microsoft's website.
|
|
|
|
|
|
Hello
I am doing vb.net and i want to create page turn effect I mean to flip page with click event or mouse event with vb.net2003 but i have no idea how start and where to start
I have search few sites but i can not find it so can you please help me with this how to do it
waiting for your kind rep.
have a nice day
thanks
|
|
|
|
|
You are going to have to do some kind of animation/paint trick to do so. How to do so is out of the scope of a forum post...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello sir
Thank you for your rep.
As you said need some annimation and paint work so i can create rectangle, with different background but main problem is how to ennimate i know that it's involve lot of maths
and i am not very good in math, So can you please give any web site so i can search on it ?
waiting for your kind rep.
thanks
|
|
|
|
|
bapu2889 wrote: it's involve lot of maths
and i am not very good in math
It shouldn't involve any real serious math like partial differential equations or anything like that. Maybe just some transformations, which can be relatively easy. http://www.mathworld.com[^] is a good reference. As far as websites on how to do page flipping, I don't really know of one. Have you tried a basic google search?
I don't have actual code how to do it, but just trying to give some ideas how it could be accomplished and that could be through some animation tricks.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello sir
first of all thank you very much for your rep.
i will try that web site
and realy want to do it and i will do it
but i dont know when
thanks again
|
|
|
|
|
Hi,
I have been working on a small application to monitor the file system and I cam across a problem. To monitor the file system I am using the File System Watcher component (I have named it filesystem) and I used the "EnableRaisingEvents" property inside a Button_Click Event to allow the user to enable/disable it. But for some reason it only half works:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If filesystem.EnableRaisingEvents = True Then
filesystem.EnableRaisingEvents = False
Else
filesystem.EnableRaisingEvents = True
End If
End Sub
When I click the button it disables the File System Watcher and if I click it again it throws an error saying "The path is not of a legal form". I've tried to stop this but watever I do it always throws the error.
Any help would be greatly appreciated,
Thanks
Lloyd J. Atkinson
|
|
|
|
|
Make sure the Path property contains a valid path.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi,
Thanks for that, I didnt have a clue before why it would'nt work!
Thanks,
Lloyd J. Atkinson
|
|
|
|
|
You're welcome.
The only thing I did was rephrase the error message...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi everyone,
I am working on billing project.
I want to print calculated amount in words for Reports.
Reports are generated in Crystal Report 8.0
e.g.
Amount = 6,45,840/- Rs.
In Words “Six Lakhs Forty Five Thousand Eight Hundred Forty Only.”
Currently I am using to “towords()” function to convert numeric value to string.
Current I am having two problems.
1) Numeric values are not displaying properly
values like 6,45,000 are displaying as 645,000. I am not able set thousand separate for values in Lakhs.
2) Words are not correct for values like 100,000 i.e. One Lakh and so on.
e.g.
If the Amount = 6,45,840/- Rs.
It is printing Words as “Six Hundred forty-five thousand eight hundred forty only”
Instead of “Six Lakhs Forty Five Thousand Eight Hundred Forty Only.”
Please tell me how to solve this problem.
I am using Crystal Report 8.0 as Reporting tool and Visual Basic 6.0
Kiran Sajanikar
Software Engineer
CleverBIT softwares.
Pune.
|
|
|
|
|
|
<br />
<br />
SqlStr = "SELECT partno, itemdetails FROM tblpurchaseitem WHERE partno in (select partno from StockMaster where stockgroup='" & Combo1.Text & "') and number in (select number from tblpurchase where pur_date>=#" & Format(mskdate, "mm/dd/yyyy") & "# and pur_date <=#" & Format(mekdate, "mm/dd/yyyy") & "# and purchase_form='Purchase') and purchase_form='Purchase' group by partno,itemdetails"<br />
<br />
hello friends i want the Sum(quantity) feild also on the reports the query works fine but someone tell me how the that feild could added to Crystal report
with regards
yogesh
|
|
|
|
|
You can calculate the sum of quantity in the Crystal Reports by just adding a formula field into the crystal reports, in the formula editor right the following code:
Sum ({TableName.ColumnName})
e.g.
Sum ({Sales.quantity})
Then just place the created formula field into your report.
Hope it helps !
AliAmjad(MCP)
|
|
|
|
|
I tried the same but it will display the th error
that is
"Error Detected by database Dll"
plz sugges the another option
regards
yogesh agarwal
|
|
|
|
|
Did you add the Table into your crystal reports document viewer under Database fields before calculating the Sum and successfully be able to connect to the database?
AliAmjad(MCP)
|
|
|
|
|
<br />
With CrystalReport1<br />
.SQLQuery = SqlStr<br />
.ReportFileName = App.Path & "\Reports\rep_ItemEnqSPG.rpt"<br />
.Formulas(0) = "startdate= '" & mskdate.Text & "'"<br />
.Formulas(1) = "enddate= '" & mekdate.Text & "'"<br />
.Formulas(2) = "name= '" & Rs!Name & "'"<br />
Wend<br />
.Action = 1<br />
End With<br />
<br />
<br />
I am not using the Viewer my code is mention above
all the feilds works fine only aggrigate function feild not working
regards
yogesh
|
|
|
|
|
Open your report rep_ItemEnqSPG.rpt and establish a connection with your database then add the table which has the quantity field then try to use the formula field.
AliAmjad(MCP)
|
|
|
|
|
I Have comleted our login form and when user input valid user name and password then he/she move to the MDI Form but I Want to close login form after enter valid username and password
from samarjeet singh
Kanpur(UP) india
samarjeet singh
(Software Engineer)
|
|
|
|
|
if you use VB then use unload function
|
|
|
|