Another Visual Basic Challenge

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
I tried something In VB, something easy when you write it in a PLC.

A running light with 8 lights.

But, booleans have to be shape backcolors or checkboxes.

I tried to change the value of a checkbox with a button, but didn't work... Changing the backcolor of a shape was no problem.

So what I tried is, a start and stop button... and then 8 shape's. First shape becomes green, then second one and first one becomes white again, the 3, etc...

I think I need to write it with For Next, that's mostly used for loops... so...

But the interval, u know, every time there is a pulse, I must change the current state and the next one, this has to work automatically...

Anyone know how to code a running light in VB ?
 
Another VB Challenge For Who?

Home work?

I want to help, but I hope you not putting a grade above the knowledge.
 
Show what have you come up with, where do you find difficulties, then somebody may help

Any way see the attachment for you to view how it works, with 12 lights. But no source code until you show your codes
 
From a previous post by Combo:

combo said:
I'm study Visual Basic on my own, so it's not homework, I just hadn't any idea how to begin on this exercise.

Combo is currently teaching himself, that's why he's asking these questions. So no, it's not anyones homework except Combo's.

I'd offer to help but I suck at VB!

:unsure:
 
I would use a timer.
I would setup the shapes as an array or put them into a collection.
Then each time the timer expires, increment to the next shape.
 
Here is one small example for PLC, it´s easy to convert to VB...

Code:
 VAR
 	i:INT:=1;
 	j: INT:=1;
 	delay:TON;
 	timing:TIME:=T#2s;
 	lights : ARRAY [1..10] OF BOOL;
 	number_leds:INT:=10;
 END_VAR
 
 
 FOR i:=1 TO number_leds DO
 	lights [i]:=(j=i);
 	delay(in:=TRUE,pt:=timing*10000/32767);
 	IF delay.q THEN
 		j:=j+1;
 		IF j > number_leds THEN
 			j:=1;
 		END_IF
 		delay(in:=FALSE);
 	END_IF
 END_FOR
 
Running Lights

Ok, Take a look at this example:

Code:
 Option Explicit
 Private mLightNumber As Integer
  
 Private Sub Form_Load()
 mLightNumber = 7
 Dim ShapeLight As Shape
 For Each ShapeLight In Me.ShapeLight
 ShapeLight.FillColor = QBColor(15)
 Next
 End Sub
  
 Private Sub cmdStart_Click()
 Me.Timer1.Enabled = True
 End Sub

 Private Sub cmdStop_Click()
 Me.Timer1.Enabled = False
 End Sub
  
 Private Sub Timer1_Timer()
 Me.ShapeLight(mLightNumber).FillColor = QBColor(15)
 mLightNumber = mLightNumber + 1
 If mLightNumber > 7 Then mLightNumber = 0
 Me.ShapeLight(mLightNumber).FillColor = QBColor(10)
 End Sub
 
Last edited:
...

My dear friend,

I am an Automation Employer for 6 years now (Siemens only). I only want to know the basics of Visual Basic because I want to buy something that I can connect to my PC and that I can program like I want. It's for an application at home, some kinda alarmsystem with magneto-contacts and webcams...

This is Home Work in some kinda way, but not for school or my job.



Corbis said:
Another VB Challenge For Who?

Home work?

I want to help, but I hope you not putting a grade above the knowledge.
 
Nice

Just what i wanted to see, thanks

chavak said:
Show what have you come up with, where do you find difficulties, then somebody may help

Any way see the attachment for you to view how it works, with 12 lights. But no source code until you show your codes
 

Similar Topics

I have 2 PLCs. One is networked to our plant, and the other is networked to the first PLC via a 1756-EN2T. I could easily get the second PLC...
Replies
3
Views
77
Hi, The hardware is: Click Plc model # CO-O1DD1-O HMI model # S3ML-R magnetic-inductive flow meter model # FMM100-1001. I will set the flow meter...
Replies
4
Views
209
So I had an odd request from a customer for the above. I have written the logic and tested it all in one PLC with only using 7 outputs and 7...
Replies
15
Views
471
Hello I need to message read the entire 16 channel raw analog inputs from a 1769-L33ER Compact Logic controller to another 1769-L33ER Compact...
Replies
8
Views
272
I am noticing a problem where i am using MOV instruction and writing literal text into source and String datatype in destination. It works fines...
Replies
6
Views
508
Back
Top Bottom