Imports System.Drawing
Imports System.Text.RegularExpressions
Imports System.Windows.Forms
Module Module1
Public Enum ValidationType
MaxMin = 1
End Enum
Public Sub AssignValidation(ByRef CTRL As TextBox, ByVal Validation_Type As ValidationType, Min As Double, Max As Double)
Dim txt As TextBox = CTRL
Select Case Validation_Type
Case ValidationType.MaxMin
AddHandler txt.TextChanged, AddressOf MaximumMinimum
End Select
End Sub
Public Sub MaximumMinimum(ByVal sender As Object, ByVal e As System.EventArgs)
Dim NO As TextBox = sender
If Val(NO.Text) < Min Then
NO.Focus()
ElseIf Val(NO.Text) > Max Then
NO.Focus()
End If
End Sub
End Module
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AssignValidation(Me.TextBox1, ValidationType.MaxMin,Zo.Min,Zo.Max)
End Sub
I have question about that code. If I have several textboxes and all textboxes will have different maximum and minimum values, those minimum and maximum values are declared in the module for each textbox, then how can I add these values to that code?
Because that code shows at a moment Min=0 and Max=0 but actually I have different values.