1

I am trying to set up a userform that will be used to take orders. e.g. each time you click the Cappuccino button it will increment the text box by one indicating that you are ordering 1, 2, 3 etc.

As far as I can get it is to only populate the text box one time. Each additional click does not appear to do anything. This is the Code I currently have for it. I tried declaring num as public. I thought that might be part of the problem but it did not seem to make a difference. Could it be a type casting issue since it is a "text" box and I am trying to treat it as in integer?

Private Sub Capuccino_Click()

   If (Cap_qty.Value = Null) Then
    Dim num As Integer
    num = 1
    Cap_qty.Value = Cap_qty.Value + num
    ElseIf (Cap_qty.Value = IsNotNull) Then
        num = num + 1
        Cap_qty.Value = num
        'Cap_qty.Value = num + 1
        'num = Cap_qty.Value

    End If
End Sub
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
Jonny
  • 11
  • 1
  • 2

1 Answers1

0

Well, that makes a difference. I looked at something somewhere that told me to use Null, IsNotNull. I was able to get it working with the following which at the moment does not make sense to me I will have to figure out why it works this way. I guess there is some background action happening that is letting me do math with stings

Private Sub CommandButton1_Click()

If (TextBox1.Value = vbNullString) Then

TextBox1.Value = 1 Else

TextBox1.Value = TextBox1.Value + 1 End If

End Sub ​

Jonny
  • 11
  • 1
  • 2