Results 1 to 5 of 5

Thread: [RESOLVED] creative minds - ideas encouraged for my project

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Location
    UK
    Posts
    10

    Resolved [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.

  2. #2
    Lively Member
    Join Date
    Nov 2007
    Location
    Rochester, NY
    Posts
    111

    Re: creative minds - ideas encouraged for my project

    Here's a grand open source example. Hope it helps you along your way.
    Please use the search function prior to posting a question and see if someone's already answered it.
    -If I helped you, please rate me, as I'd do the same for you =)
    -Remember to select the Resolved option for your post when you've gotten the answers you need.

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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:
    1. Dim i as long, w as long, h as long
    2. For i = 1 To Label1.UBound
    3.     Unload Label1(i)
    4. Next
    5. w = Label1(0).Width
    6. h = Label1(0).Height
    7. For i = 1 To 69
    8.     Load Label1(i)
    9.     With Label1(i)
    10.         Select Case i Mod 7
    11.             Case 0: .Move (Label1(0).Width + 500) * (i \ 7) + Label1(0).Left, Label1(0).Top
    12.             Case 1: .Move Label1((i \ 7) * 7).Left + w, Label1(0).Top + h, h, w
    13.             Case 2: .Move Label1((i \ 7) * 7).Left + w, Label1(0).Top + 2 * h + w, h, w
    14.             Case 3: .Move Label1((i \ 7) * 7).Left, Label1(0).Top + 2 * h + 2 * w
    15.             Case 4: .Move Label1((i \ 7) * 7).Left - h, Label1(0).Top + 2 * h + w, h, w
    16.             Case 5: .Move Label1((i \ 7) * 7).Left - h, Label1(0).Top + h, h, w
    17.             Case 6: .Move Label1((i \ 7) * 7).Left, Label1(0).Top + h + w: .Visible = True
    18.         End Select
    19.         .Visible = Not .Visible
    20.     End With
    21. Next
    22. Label1(0).Visible = True
    23. sw = Me.Width - Me.ScaleWidth
    24. sh = Me.Height - Me.ScaleHeight
    25. 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:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2.       Dim i As Long, j As Long, mystr As String, x as long
    3.       If KeyAscii = 13 Then
    4.       KeyAscii = 0
    5.       For i = 0 To Label1.UBound
    6.           Label1(i).Visible = False
    7.       Next
    8.       For i = 1 To Len(Text1)
    9.           Select Case Mid(Text1, i, 1)
    10.               Case 1: mystr = "12"
    11.               Case 2: mystr = "01643"
    12.               Case 3: mystr = "01236"
    13.               Case 4: mystr = "5612"
    14.               Case 5: mystr = "05623"
    15.               Case 6: mystr = "54326"
    16.               Case 7: mystr = "012"
    17.               Case 8: mystr = "0123456"
    18.               Case 9: mystr = "01256"
    19.               Case 0: mystr = "012345"
    20.           End Select
    21.            For j = 1 To Len(mystr)
    22.             x = Mid(mystr, j, 1) + (((i - 1) Mod 7) + ((i - 1) \ 7) * 7) * 7
    23.               Label1(x).Visible = True
    24.           Next
    25.       Next
    26.       End If
    27.       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
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Location
    UK
    Posts
    10

    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Location
    UK
    Posts
    10

    Re: creative minds - ideas encouraged for my project

    westconn1,
    that code will be VERY helpful. =] many thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width