I need some help on this program that i have. i can't seem to get it to work.
any comment on the program would be appreciated.
Thx in advance.
I have uploaded my program in case u need to take a look.

Dim first As Double
Dim second As Double
Dim sign As String

Private Sub lbldot_Click()
     If InStr(txtdisplay.Text, ".") = 0 Then
          txtdisplay.Text = txtdisplay.Text & "."
     End If
End Sub

Private Sub lblnumber_Click(Index As Integer)
     If txtdisplay.Text = "" Then
     txtdisplay.Text = lblnumber(Index).Caption
     Else
          txtdisplay.Text = txtdisplay.Text & lblnumber(Index).Caption
     End If
End Sub

Private Sub lblsign_Click(Index As Integer)
     first = txtdisplay.Text
     txtdisplay.Text = ""
     sign = lblsign(Index).Caption
End Sub
Private Sub cmdEq_Click()
     txtdisplay.Text = second
     sign = lblsign(Index).Caption
     If sign = "-" Then
          txtdisplay.Text = first - second
     ElseIf sign = "+" Then
          txtdisplay.Text = first + second
     ElseIf sign = "*" Then
          txtdisplay.Text = first * second
     ElseIf sign = "/" Then
          txtdisplay.Text = first / second
     End If
End Sub
Private Sub cmdClear_Click()
    txtdisplay.Text = ""
End Sub
Private Sub cmdDot_Click()
     If InStr(txtdisplay.Text, ".") = 0 Then
          txtdisplay.Text = txtdisplay.Text & "."
     End If
End Sub
Private Sub Form_Load()
txtdisplay.Enabled = False
End Sub

You didn't assign the numbers to first and second. And in Private Sub cmdEq_Click() , you can remove the sign = lblsign(Index).caption because it is not necessary and if not removed will alter the results.

Sorry for the double post. I didn't see the assigning of the variables the first time. Please look in the sub Eq_Click() , txtdisplay.Text = second must be second = txtdisplay.Text . You reversed the assignment.

You didn't assign the numbers to first and second. And in Private Sub cmdEq_Click() , you can remove the sign = lblsign(Index).caption because it is not necessary and if not removed will alter the results.

so How do i asssaign the numbers to first and second?
and can you help me with the cmdEq button. it's not working properly.

so How do i asssaign the numbers to first and second?
and can you help me with the cmdEq button. it's not working properly.

Like I said in my second post, I didn't see that you have already assigned numbers for your variables and that you reversed the assigning process to second. Now, however, I figured out another problem. If you'd check the captions of your lblsign's, spaces are included, meaning that for the "+" label, the caption is not "+" but " +" and the same for the others. Either you change the captions such that spaces are deleted, or you could change your assignment codes. My best suggestion is that you use Trim$ function to omit any space included. In short, use these:

In the lblsign_Click sub,

first = Trim$(txtDisplay.Text)

In the cmdEq_Click sub,

second = Trim$(txtDisplay.Text)

The other solution is to delete the spaces in the captions of your lblsign's and change the alignment property to 2-Center so that the signs would still appear at the center.

And I repeat!!! The txtDisplay.Text = second should be second = txtDisplay.Text should you use the latter solution.

Whoops! What's gotten into me? My memory must be fading, or maybe I'm just too sleepy right now. Once again, everyone, I'm sorry for double posts. I do hope this will be the last time.

Er, wrong solution. It should be that in the lblsign_Click sub, it must be sign = Trim(lblsign(Index).caption) . Next, as I said before, it should be second = txtDisplay.text and delete the sign = lblsign(Index).caption in the cmdEq_Click sub.

Once again, I'm very sorry.:$

I have changed the code accordign to ur suggestions. I also made the cmdEq into a control array as well, like "-" "+"...
Please take a look and correct me

Dim first As Double
Dim second As Double
Dim sign As String

Private Sub lbldot_Click()
     If InStr(txtdisplay.Text, ".") = 0 Then
          txtdisplay.Text = txtdisplay.Text & "."
     End If
End Sub

Private Sub lblnumber_Click(Index As Integer)
     If txtdisplay.Text = "" Then
     txtdisplay.Text = lblnumber(Index).Caption
     Else
          txtdisplay.Text = txtdisplay.Text & lblnumber(Index).Caption
     End If
End Sub

Private Sub lblsign_Click(Index As Integer)
first = txtdisplay.Text
     txtdisplay.Text = ""
     sign = Trim(lblsign(Index).Caption)
txtdisplay.Text = second
     If sign = "-" Then
          txtdisplay.Text = first - second
     ElseIf sign = "+" Then
          txtdisplay.Text = first + second
     ElseIf sign = "*" Then
          txtdisplay.Text = first * second
     ElseIf sign = "/" Then
          txtdisplay.Text = first / second
     End If
End Sub
Private Sub cmdClear_Click()
    txtdisplay.Text = ""
End Sub
Private Sub cmdDot_Click()
     If InStr(txtdisplay.Text, ".") = 0 Then
          txtdisplay.Text = txtdisplay.Text & "."
     End If
End Sub
Private Sub Form_Load()
txtdisplay.Enabled = False
End Sub

Ok, so you have made the equals into a label as well and it has an index of 4? Let's look at your lblsign_click Sub. It assigns a value to first, then deletes the text in txtdisplay, then assigns the sign which could be "=" and this will make an error later on. Next, txtdisplay.text will be equal to the value of second, to which you have not assigned a variable. If you allow me to correct part of the code, I'm going to add 2 new boolean variables called check which will check if one of the variables have already been assigned a value and checktext which will decide when to clear the textbox during continuous arithmetic processes. So the editions are:

Dim check as Boolean
Dim checktext as Boolean
 
Private Sub lblnumber_Click(Index As Integer)
    If checktext = True Then
        txtdisplay.Text = ""
        checktext = False
    End If
    If txtdisplay.Text = "" Then
    txtdisplay.Text = lblnumber(Index).Caption
    Else
        txtdisplay.Text = txtdisplay.Text & lblnumber(Index).Caption
    End If
End Sub
 
Private Sub lblsign_Click(Index As Integer)
    If check = False Then
        second = txtdisplay.Text
        sign = Trim(lblsign(Index).Caption)
        If Index < 4 Then check = True
    Else
        first = second
        second = txtdisplay.Text
        txtdisplay.Text = ""
        If sign = "-" Then
            txtdisplay.Text = first - second
        ElseIf sign = "+" Then
            txtdisplay.Text = first + second
        ElseIf sign = "*" Then
            txtdisplay.Text = first * second
        ElseIf sign = "/" Then
            txtdisplay.Text = first / second
        End If
        second = txtdisplay.Text
        If Index < 4 Then
            sign = Trim(lblsign(Index).Caption)
        Else
            check = False
        End If
    End If
    checktext = True
End Sub
 
Private Sub cmdClear_Click()
    txtdisplay.Text = ""
    check = False
    checktext = False
End Sub

Let me know if this works.

Ok, so you have made the equals into a label as well and it has an index of 4? Let's look at your lblsign_click Sub. It assigns a value to first, then deletes the text in txtdisplay, then assigns the sign which could be "=" and this will make an error later on. Next, txtdisplay.text will be equal to the value of second, to which you have not assigned a variable. If you allow me to correct part of the code, I'm going to add 2 new boolean variables called check which will check if one of the variables have already been assigned a value and checktext which will decide when to clear the textbox during continuous arithmetic processes. So the editions are:

Dim check as Boolean
Dim checktext as Boolean
 
Private Sub lblnumber_Click(Index As Integer)
    If checktext = True Then
        txtdisplay.Text = ""
        checktext = False
    End If
    If txtdisplay.Text = "" Then
    txtdisplay.Text = lblnumber(Index).Caption
    Else
        txtdisplay.Text = txtdisplay.Text & lblnumber(Index).Caption
    End If
End Sub
 
Private Sub lblsign_Click(Index As Integer)
    If check = False Then
        second = txtdisplay.Text
        sign = Trim(lblsign(Index).Caption)
        If Index < 4 Then check = True
    Else
        first = second
        second = txtdisplay.Text
        txtdisplay.Text = ""
        If sign = "-" Then
            txtdisplay.Text = first - second
        ElseIf sign = "+" Then
            txtdisplay.Text = first + second
        ElseIf sign = "*" Then
            txtdisplay.Text = first * second
        ElseIf sign = "/" Then
            txtdisplay.Text = first / second
        End If
        second = txtdisplay.Text
        If Index < 4 Then
            sign = Trim(lblsign(Index).Caption)
        Else
            check = False
        End If
    End If
    checktext = True
End Sub
 
Private Sub cmdClear_Click()
    txtdisplay.Text = ""
    check = False
    checktext = False
End Sub

Let me know if this works.

um..no it does not work

when you press the equal sign the error about the second=txtdisplay.text shows up

Could you specify which second = txtdisplay.text causes the error? And what type of error it is?

Could you specify which second = txtdisplay.text causes the error? And what type of error it is?

the first second=txtdisplay.text under lblSign_Click
and it's argument not optional

This question has already been answered. Start a new discussion instead.