none
Simple question newbie to .net RRS feed

  • Question

  • I am creating an application in vb.net for a manufacturing test.  At the end of the test, I am using a windows form to display either PASS on a green background or FAIL on a red background.  Everything is working, but when I call the second form to show the label always appears as no text with a white background.   Feel stupid that I can't figure out what is going on.  The problem I have is that I had done a lot of programming in VB6, but have gotten away from development altogether until recently.

    If blnPassFail = True

          me.lblpassfail.text = "PASS"

         me.lblpassfail.backcolor=color.green

         me.backcolor=color.green

    Else

         me.lblpassfail.text = "FAIL"

         me.lblpassfail.backcolor = color.red

         me.backcolor = color.red

    Endif

    The label always just shows as a white box on the form.  The forecolor is black, the text is arial 72.  Can't figure it out.

    Thursday, November 5, 2015 5:59 PM

Answers

  • Hi JOEP88,

    I tested you code, it works fine on my side.  I put your code in my Form_Load method.

        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim blnPassFail As Boolean = False
            If blnPassFail = True Then
                Me.lblpassfail.Text = "PASS"
                Me.lblpassfail.BackColor = Color.Green
                Me.BackColor = Color.Green
            Else
                Me.lblpassfail.Text = "FAIL"
                Me.lblpassfail.BackColor = Color.Red
                Me.BackColor = Color.Red
            End If
        End Sub

    Where did you put your code? You need to determine whether your code is executed or not.  You could set a breakpoint in your code to debug it.

    Best Regards,
    Jerry

    Friday, November 6, 2015 2:01 AM