Page 1 of 1

Segment Arrays Making a Digital number Rate Topic: -----

#1 sam_benne  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 16
  • View blog
  • Posts: 732
  • Joined: 16-January 08

Posted 26 January 2008 - 03:05 PM

In this tutorial you will be shown how to make a segment array. This will allow you to make a digital number.
This is a simple project but can be quite hard.

To make this you will need a form two buttons (command1 and CmdShowNumber) 7 shapes 0ne frame with 10 option buttons in it and one text box.

First with the form make sure you have the backcolor as &H80000000& this is so that the shapes will blend in.
the size of the form should be width - 7575 and height - 9300. Also make sure you have the setting show in task bar set true.

Once the Form is set up the next stage is to save the form with an appropriate name.

Now you should create a frame which is the same color as the form but change the color when we finish adding the shapes. For now also it doesn't matter what size it is but make it large so we have space to do work but later we will make it smaller. Lastly remove the name and border as we don't need these.

In this frame we need to shapes. You need to change their Bordercolor and Fillcolor to the same as the background also they need to be a rounded rectangle which you can change in the shape option. One of the shapes needs it height to be 615 and its width needs to be 2295. The other one needs to be opposite height - 2295 and width - 615. The taller one you need to copy and paste in the frame 3 times so you have four of them and do the same to the other but only twice so you have three all together. Once you have these you need to arrange them into an eight shape like you would find on a calculator. When you have arranged them into the number eight you will need to name them start with the top one and go clockwise and name them shp1 to shp7. Hence it being a seven segment array.

When you have named your shapes you need to make the frame smaller so it just fits around them so that next to it you can place another frame. But this time you can keep it the same color and give it a name like "Options" or something. and in this frame you need to place 10 option buttons and from the top give them a caption going from 1 to 10. these option buttons will be the bases of the (SSA). You also need to name the opt then add the number of the option button.

The next stage is to add a command button underneath called CmdShowNumber and simply saying "Show Number". now double click the button so that you can go into code mode. This is really simple as the code may seem big but it is really simple.

If opt1 = True Then
	' Make block show blue and 'border as blue
		shpR1.FillColor = vbBlue
			shpR1.BackColor = vbBlue
		shpR2.FillColor = vbBlue
			shpR2.BackColor = vbBlue
		shpR3.FillColor = vbBlue
			shpR3.BackColor = vbBlue
		shpR4.FillColor = vbBlue
			shpR4.BackColor = vbBlue
		shpR6.FillColor = &H8000000F
			shpR6.BackColor = &H8000000F
		shpR5.FillColor = vbBlue
			shpR5.BackColor = vbBlue
		shpR7.FillColor = vbBlue
			shpR7.BackColor = vbBlue
End If

If opt2 = True Then
		shpR1.FillColor = &H8000000F
			shpR1.BackColor = &H8000000F
		shpR2.FillColor = vbBlue
			shpR2.BackColor = vbBlue
		shpR3.FillColor = vbBlue
			shpR3.BackColor = vbBlue
		shpR4.FillColor = &H8000000F
			shpR4.BackColor = &H8000000F
		shpR5.FillColor = &H8000000F
			shpR5.BackColor = &H8000000F
		shpR6.FillColor = &H8000000F
			shpR6.BackColor = &H8000000F
		shpR7.FillColor = &H8000000F
			shpR7.BackColor = &H8000000F
End If

If opt3 = True Then
		shpR1.FillColor = vbBlue
			shpR1.BackColor = vbBlue
		shpR2.FillColor = vbBlue
			shpR2.BackColor = vbBlue
		shpR3.FillColor = &H8000000F
			shpR3.BackColor = &H8000000F
		shpR6.FillColor = vbBlue
			shpR6.BackColor = vbBlue
		shpR4.FillColor = vbBlue
			shpR4.BackColor = vbBlue
		shpR5.FillColor = vbBlue
			shpR5.BackColor = vbBlue
		shpR7.FillColor = &H8000000F
			shpR7.BackColor = &H8000000F
End If

If opt4 = True Then
		shpR1.FillColor = vbBlue
			shpR1.BackColor = vbBlue
		shpR2.FillColor = vbBlue
			shpR2.BackColor = vbBlue
		shpR6.FillColor = vbBlue
			shpR6.BackColor = vbBlue
		shpR4.FillColor = vbBlue
			shpR4.BackColor = vbBlue
		shpR3.FillColor = vbBlue
			shpR3.BackColor = vbBlue
		shpR7.FillColor = &H8000000F
			shpR7.BackColor = &H8000000F
		shpR5.FillColor = &H8000000F
			shpR5.BackColor = &H8000000F
End If

If opt5 = True Then
		shpR1.FillColor = &H8000000F
			shpR1.BackColor = &H8000000F
		shpR7.FillColor = vbBlue
			shpR7.BackColor = vbBlue
		shpR2.FillColor = vbBlue
			shpR2.BackColor = vbBlue
		shpR6.FillColor = vbBlue
			shpR6.BackColor = vbBlue
		shpR3.FillColor = vbBlue
			shpR3.BackColor = vbBlue
		shpR4.FillColor = &H8000000F
			shpR4.BackColor = &H8000000F
		shpR5.FillColor = &H8000000F
			shpR5.BackColor = &H8000000F
End If

If opt6 = True Then
		shpR1.FillColor = vbBlue
			shpR1.BackColor = vbBlue
		shpR2.FillColor = &H8000000F
			shpR2.BackColor = &H8000000F
		shpR7.FillColor = vbBlue
			shpR7.BackColor = vbBlue
		shpR6.FillColor = vbBlue
			shpR6.BackColor = vbBlue
		shpR4.FillColor = vbBlue
			shpR4.BackColor = vbBlue
		shpR3.FillColor = vbBlue
			shpR3.BackColor = vbBlue
		shpR5.FillColor = &H8000000F
			shpR5.BackColor = &H8000000F
End If

If opt7 = True Then
		shpR1.FillColor = vbBlue
			shpR1.BackColor = vbBlue
		shpR3.FillColor = vbBlue
			shpR3.BackColor = vbBlue
		shpR4.FillColor = vbBlue
			shpR4.BackColor = vbBlue
		shpR5.FillColor = vbBlue
			shpR5.BackColor = vbBlue
		shpR6.FillColor = vbBlue
			shpR6.BackColor = vbBlue
		shpR7.FillColor = vbBlue
			shpR7.BackColor = vbBlue
End If

If opt8 = True Then
		shpR1.FillColor = vbBlue
			shpR1.BackColor = vbBlue
		shpR2.FillColor = vbBlue
			shpR2.BackColor = vbBlue
		shpR3.FillColor = vbBlue
			shpR3.BackColor = vbBlue
		shpR4.FillColor = &H8000000F
			shpR4.BackColor = &H8000000F
		shpR5.FillColor = &H8000000F
			shpR5.BackColor = &H8000000F
		shpR6.FillColor = &H8000000F
			shpR6.BackColor = &H8000000F
		shpR7.FillColor = &H8000000F
			shpR7.BackColor = &H8000000F
End If

If opt9 = True Then
		shpR1.FillColor = vbBlue
			shpR1.BackColor = vbBlue
		shpR2.FillColor = vbBlue
			shpR2.BackColor = vbBlue
		shpR3.FillColor = vbBlue
			shpR3.BackColor = vbBlue
		shpR4.FillColor = vbBlue
			shpR4.BackColor = vbBlue
		shpR5.FillColor = vbBlue
			shpR5.BackColor = vbBlue
		shpR6.FillColor = vbBlue
			shpR6.BackColor = vbBlue
		shpR7.FillColor = vbBlue
			shpR7.BackColor = vbBlue
End If

If opt10 = True Then
		shpR1.FillColor = vbBlue
			shpR1.BackColor = vbBlue
		shpR2.FillColor = vbBlue
			shpR2.BackColor = vbBlue
		shpR3.FillColor = vbBlue
			shpR3.BackColor = vbBlue
		shpR6.FillColor = vbBlue
			shpR6.BackColor = vbBlue
		shpR7.FillColor = vbBlue
			shpR7.BackColor = vbBlue
		shpR4.FillColor = &H8000000F
			shpR4.BackColor = &H8000000F
		shpR5.FillColor = &H8000000F
			shpR5.BackColor = &H8000000F
End If


This is a really simple if statement. what it does is if an option button is clicked, it will look for the one you clicked then change the Fillcolor and Bordercolor.

Now hit F5 and test.

You have just created a seven segment array. Well Done.

If you would like to see what it should look like then check the attachment and also soon there will be a new tutorial of using a text box in stead of option buttons and also the (SSA) with a timer.

If you have any problems just comment or contact me (sam_benne@hotmail.co.uk) or if you have any questions.

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Page 1 of 1