Neviem si vysvetliť, prečo nižšie uvedený kód nefunguje. Potrebujem zastaviť NumericUpDown až dosiahne určitú hodnotu. Ak klikám na šipku down, tak to funguje. Ale ak ju držím, tak vyhodí chybu: NullReferenceException was unhandled
Public Class Form1
Dim ptA As New Point(20, 10)
Dim ptB As New Point(50, 10)
Dim ptPom As Point
Dim sirka As Integer = 50
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
NumericUpDown1.Maximum = 50
NumericUpDown1.Value = 50
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
ptPom.X = ptB.X
ptPom.X = ptPom.X + NumericUpDown1.Value - sirka
If ptPom.X = ptA.X Then
MsgBox(" Body 'A' a 'B' sa nemôžu prekrývať")
NumericUpDown1.Value = sirka
Else
sirka = NumericUpDown1.Value
ptB.X = ptPom.X
End If
End Sub
End Class
|