numeric up down problem

short description of my program:

I have a listbox with therein orderlines (an orderline exists of order number sparepart, description,prize, quantity) now I'm able to change the quantities with an numericupdown(NUD).

I have 2 problems:

1) When someone uses backspace or delete in the NUD and then klick a different orderline the the NUD should be zero again, but it stays empty.

2) When I click the NUD with the Mouse and then a number eg. 5 then in the NUD stand 05 and this should be 5.

can anybody help me?

[1091 byte] By [Vermeulen] at [2008-1-8]
# 1

answer for problem 1

Code Snippet

Private Sub nudNumber_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudNumber.Leave

If nudNumber.Controls.Item(1).Text = "" Then

nudNumber.Controls.Item(1).Text = "0"

nudNumber.Value = 0

End If

End Sub

answer for problem 2

Code Snippet

Private Sub nudNumber_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles nudNumber.KeyDown

If e.KeyCode <> Keys.Back And e.KeyCode <> Keys.Delete Then

nudNumber_ValueChanged(sender, e)

If nudNumber.Controls.Item(1).Text = "0" Then

nudNumber.Controls.Item(1).Text = ""

End If

End If

End Sub

Vermeulen at 2007-10-2 > top of Msdn Tech,Visual Basic,Visual Basic Language...