5 Replies - 343 Views - Last Post: 05 December 2011 - 01:57 AM Rate Topic: -----

#1 Zafeer.H  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 04-December 11

Help writing code, different topic.

Posted 05 December 2011 - 12:36 AM

 Public Class Form1

    Private Sub PictureBox7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox7.Click

    End Sub

    Private Sub ShowDigit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowDigit.Click
        Dim Digit1 As Integer = DigitValue.Text
        If Digit1 = 0 Then
            PictureBox1.Visible = True
            PictureBox2.Visible = True
            PictureBox3.Visible = True
            PictureBox5.Visible = True
            PictureBox6.Visible = True
            PictureBox7.Visible = True
            PictureBox4.Visible = False
        End If
        If Digit1 = 1 Then
            PictureBox1.Visible = True
            PictureBox2.Visible = True
            PictureBox3.Visible = True
            PictureBox5.Visible = True
            PictureBox6.Visible = True
            PictureBox7.Visible = True
            PictureBox4.Visible = False
        End If
        If Digit1 = 2 Then
            PictureBox1.Visible = True
            PictureBox2.Visible = True
            PictureBox3.Visible = True
            PictureBox5.Visible = True
            PictureBox6.Visible = True
            PictureBox7.Visible = True
            PictureBox4.Visible = False
        End If
        If Digit1 = 3 Then
            PictureBox1.Visible = True
            PictureBox2.Visible = True
            PictureBox3.Visible = True
            PictureBox5.Visible = True
            PictureBox6.Visible = True
            PictureBox7.Visible = True
            PictureBox4.Visible = False
        End If

        If Digit1 = 4 Then
            PictureBox1.Visible = True
            PictureBox2.Visible = True
            PictureBox3.Visible = True
            PictureBox5.Visible = True
            PictureBox6.Visible = True
            PictureBox7.Visible = True
            PictureBox4.Visible = False
        End If
        If Digit1 = 5 Then
            PictureBox1.Visible = True
            PictureBox2.Visible = True
            PictureBox3.Visible = True
            PictureBox5.Visible = True
            PictureBox6.Visible = True
            PictureBox7.Visible = True
            PictureBox4.Visible = False
        End If
        If Digit1 = 6 Then
            PictureBox1.Visible = True
            PictureBox2.Visible = True
            PictureBox3.Visible = True
            PictureBox5.Visible = True
            PictureBox6.Visible = True
            PictureBox7.Visible = True
            PictureBox4.Visible = False
        End If
        If Digit1 = 7 Then
            PictureBox1.Visible = True
            PictureBox2.Visible = True
            PictureBox3.Visible = True
            PictureBox5.Visible = True
            PictureBox6.Visible = True
            PictureBox7.Visible = True
            PictureBox4.Visible = False
        End If
        DigitValue.Text = DigitValue.Text + 1



    End Sub

    Private Sub AddOne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddOne.Click
        ShowDigit_Click(sender, e)
    End Sub

    Private Sub ShowDigit2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowDigit2.Click
        Dim Digit As Integer = OneSecs.Text
        If Digit = 0 Then
            PictureBox8.Image = Image.FromFile("C:\Users\Zafeer Hussain\Desktop\0.jpg")
        End If

        If Digit = 1 Then
            PictureBox8.Image = Image.FromFile("C:\Users\Zafeer Hussain\Desktop\1.jpg")
        End If

        If Digit = 2 Then
            PictureBox8.Image = Image.FromFile("C:\Users\Zafeer Hussain\Desktop\2.jpg")
        End If
        If Digit = 3 Then
            PictureBox8.Image = Image.FromFile("C:\Users\Zafeer Hussain\Desktop\3.jpg")
        End If
        If Digit = 4 Then
            PictureBox8.Image = Image.FromFile("C:\Users\Zafeer Hussain\Desktop\4.jpg")
        End If
        If Digit = 5 Then
            PictureBox8.Image = Image.FromFile("C:\Users\Zafeer Hussain\Desktop\5.jpg")
        End If
        If Digit = 6 Then
            PictureBox8.Image = Image.FromFile("C:\Users\Zafeer Hussain\Desktop\6.jpg")
        End If
        If Digit = 7 Then
            PictureBox8.Image = Image.FromFile("C:\Users\Zafeer Hussain\Desktop\7.jpg")
        End If
        If Digit = 8 Then
            PictureBox8.Image = Image.FromFile("C:\Users\Zafeer Hussain\Desktop\8.jpg")
        End If
        If Digit = 9 Then
            PictureBox8.Image = Image.FromFile("C:\Users\Zafeer Hussain\Desktop\9.jpg")
        End If
    End Sub
End Class 


Hey guys Helppp!!! here is my dilemma,
When the original 7 segment display reaches 9 it goes back to show from 0 again.
How do I add code to the end of the code in AddOne_Click so that when DigitValue is greater than 9 it does 2 things makes DigitValue textbox to be 0, and adds 1 to the value in textbox OneSecs. This will have the effect of making the 7 segment display just show 0 9 and whenever it reaches 9 then a 1 is added on to the OneSecs display, so a bigger number of displayed.
Then at the end of AddOne make the code automatically click on ShowDigit2 so it updates the display digit 2 just like it displayed the digit 1??

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Help writing code, different topic.

#2 Zafeer.H  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 04-December 11

Re: Help writing code, different topic.

Posted 05 December 2011 - 12:47 AM

Can anyone help?? :S :(
Was This Post Helpful? 0
  • +
  • -

#3 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,991
  • Joined: 08-June 10

Re: Help writing code, different topic.

Posted 05 December 2011 - 01:05 AM

View PostZafeer.H, on 05 December 2011 - 07:36 AM, said:

How do I add code to the end of the code in AddOne_Click so that when DigitValue is greater than 9 it does 2 things

You use an If statement, just like you do several times in that code, using the > (greater than) operator to see if the Text property of the DigitValue field is greater than 9.

View PostZafeer.H, on 05 December 2011 - 07:36 AM, said:

makes DigitValue textbox to be 0, and adds 1 to the value in textbox OneSecs.

What exactly is the problem with this part? The first part is obvious: you just set the Text property to 0. The second part was already answered in your previous thread, just about another textbox. (They all work the same.)

View PostZafeer.H, on 05 December 2011 - 07:36 AM, said:

Then at the end of AddOne make the code automatically click on ShowDigit2 so it updates the display digit 2 just like it displayed the digit 1??

But you just said it: "just like it displayed the digit 1".
You already have a line in AddOne_Click that triggers ShowDigit_Click. The same exact thing could be done for ShowDigit2_Click.


Also, like I did in the previous thread, I would point out that all eight if blocks in ShowDigit2_Click do the exact same thing. There is no point in having a list of conditional statements if they all end up doing the same thing. You may as well have one that covers all cases, or just remove the conditionals altogether and put the code right there to be executed in any case.
Was This Post Helpful? 0
  • +
  • -

#4 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Help writing code, different topic.

Posted 05 December 2011 - 01:31 AM

If Digitvalue > 9 Then
DigitValueTextBox.Text = "0"
OnesecsTextBox.Text = OnesecsTextBox.Text+1
End If


HTH man!
Was This Post Helpful? 0
  • +
  • -

#5 Zafeer.H  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 04-December 11

Re: Help writing code, different topic.

Posted 05 December 2011 - 01:52 AM

Thanks jimmyBo again. But does the first and second line go under AddOne_Click? And the last line under OneSecs_TextChanged?

Because if I put the last line underneath One_Secs.TextChanged the follwing comes up:
An unhandled exception of type 'System.StackOverflowException' occurred in Microsoft.VisualBasic.dll
Was This Post Helpful? 0
  • +
  • -

#6 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Help writing code, different topic.

Posted 05 December 2011 - 01:57 AM

View PostZafeer.H, on 05 December 2011 - 06:52 PM, said:

Thanks jimmyBo again. But does the first and second line go under AddOne_Click? And the last line under OneSecs_TextChanged?

Because if I put the last line underneath One_Secs.TextChanged the follwing comes up:
An unhandled exception of type 'System.StackOverflowException' occurred in Microsoft.VisualBasic.dll

I assume that this code would go under your ShowDigit sub - depends on what you want to do :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1