[RESOLVED] creative minds - ideas encouraged for my project
I am creating a project in VB 6.
I will be simulating the display of a petrol pump via seven segment display & buttons to simulate taking the petrol pump in and out.
I am unsure if anyone has tried creating a 7 segment display and perhaps if so, any tips for how to structure the code etc? Been looking at sites and most of them are actual software for creating it and costs money...
Any other cool ideas to make it more life like, or better advances on my ideas are welcome. I'll the specification to anyone who wants it.
Any help/ideas would greatly appreciated.:thumb: :wave:
Re: creative minds - ideas encouraged for my project
Here's a grand open source example. Hope it helps you along your way.
Re: creative minds - ideas encouraged for my project
here is some basic code to create a display using labels,
put a label on a form about 500 wide by 135 high, somewhere near the left side, give it some colour
either put this into form load or a command button
vb Code:
Dim i as long, w as long, h as long
For i = 1 To Label1.UBound
Unload Label1(i)
Next
w = Label1(0).Width
h = Label1(0).Height
For i = 1 To 69
Load Label1(i)
With Label1(i)
Select Case i Mod 7
Case 0: .Move (Label1(0).Width + 500) * (i \ 7) + Label1(0).Left, Label1(0).Top
Case 1: .Move Label1((i \ 7) * 7).Left + w, Label1(0).Top + h, h, w
Case 2: .Move Label1((i \ 7) * 7).Left + w, Label1(0).Top + 2 * h + w, h, w
Case 3: .Move Label1((i \ 7) * 7).Left, Label1(0).Top + 2 * h + 2 * w
Case 4: .Move Label1((i \ 7) * 7).Left - h, Label1(0).Top + 2 * h + w, h, w
Case 5: .Move Label1((i \ 7) * 7).Left - h, Label1(0).Top + h, h, w
Case 6: .Move Label1((i \ 7) * 7).Left, Label1(0).Top + h + w: .Visible = True
End Select
.Visible = Not .Visible
End With
Next
Label1(0).Visible = True
sw = Me.Width - Me.ScaleWidth
sh = Me.Height - Me.ScaleHeight
Me.Width = (Label1(0).Width + 500) * (i \ 7) + (2 * Label1(0).Left) - s - h * 2
to put a value in the display add a text box, where you can type the number of digits up to the number in the display
vb Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim i As Long, j As Long, mystr As String, x as long
If KeyAscii = 13 Then
KeyAscii = 0
For i = 0 To Label1.UBound
Label1(i).Visible = False
Next
For i = 1 To Len(Text1)
Select Case Mid(Text1, i, 1)
Case 1: mystr = "12"
Case 2: mystr = "01643"
Case 3: mystr = "01236"
Case 4: mystr = "5612"
Case 5: mystr = "05623"
Case 6: mystr = "54326"
Case 7: mystr = "012"
Case 8: mystr = "0123456"
Case 9: mystr = "01256"
Case 0: mystr = "012345"
End Select
For j = 1 To Len(mystr)
x = Mid(mystr, j, 1) + (((i - 1) Mod 7) + ((i - 1) \ 7) * 7) * 7
Label1(x).Visible = True
Next
Next
End If
End Sub
this example creates a 10 digit display, to change the number of digits just change value in for loop from 69, seven digits would be 48
there is no error checking or validation of the text typed in the textbox, and i haven't got round to working from the right hand end or decimal places yet
Re: creative minds - ideas encouraged for my project
hey thanks for that i'm going to check it out in depth later but looks to be good! cheers.
Re: creative minds - ideas encouraged for my project
westconn1,
that code will be VERY helpful. =] many thanks.