S
Sparky Arbuckle
----------------------------------------
..vb Code
Imports System
Namespace ValidateComponents
Dim res As Boolean
Dim strISBN as string = tbISBNNumber.text
Dim checkISBN as string
Dim Number As String
Dim CheckDigit As String
Dim CheckValue As Integer
Dim CheckSum As Integer
Dim i As Byte
Dim Cnt As Byte
res = False
CheckDigit = UCase(Right(strISBN, 1))
Number = Trim(Replace(Left(strISBN, Len(strISBN) - 1), "-", ""))
IF (Len(Number) = 9) And (InStr(1, "0123456789X", CheckDigit) > 0)
THEN
IF CheckDigit = "X" THEN
CheckSum = 10
ELSE
CheckSum = CInt(CheckDigit)
END IF
Cnt = 1
FOR i = 1 To 9
CheckSum = CheckSum + CInt(Mid(Number, i, 1)) * (11 - Cnt)
Cnt = Cnt + 1
NEXT
IF (CheckSum Mod 11 = 0) THEN res = True
END IF
checkISBN = res
END Namespace
------------------------------------------------
..aspx page CODE
Sub ValidateISBN(s as Object, e As ServerValidateEventArgs)
Dim objValidateISBN as New ValidateISBN
lblResult.text = objValidateISBN.ValidateISBN(e.value)
END Sub
Sub Button_Click(s as Object, e as EventArgs)
IF IsValid THEN lblResult.text = "a"
IF NOT IsValid THEN lblResult.text = "b"
END Sub
----------------------------------------
The problem I am having is that the text in lblResult is not b when I
input an invalid ISBN. If res = TRUE then it is valid and if res =
FALSE then the ISBN is invalid. I don't know how to pass the value of
res from the Business object to the .aspx page. I imported the same
namespace so I know that isn't the problem. Any suggestions?
..vb Code
Imports System
Namespace ValidateComponents
Dim res As Boolean
Dim strISBN as string = tbISBNNumber.text
Dim checkISBN as string
Dim Number As String
Dim CheckDigit As String
Dim CheckValue As Integer
Dim CheckSum As Integer
Dim i As Byte
Dim Cnt As Byte
res = False
CheckDigit = UCase(Right(strISBN, 1))
Number = Trim(Replace(Left(strISBN, Len(strISBN) - 1), "-", ""))
IF (Len(Number) = 9) And (InStr(1, "0123456789X", CheckDigit) > 0)
THEN
IF CheckDigit = "X" THEN
CheckSum = 10
ELSE
CheckSum = CInt(CheckDigit)
END IF
Cnt = 1
FOR i = 1 To 9
CheckSum = CheckSum + CInt(Mid(Number, i, 1)) * (11 - Cnt)
Cnt = Cnt + 1
NEXT
IF (CheckSum Mod 11 = 0) THEN res = True
END IF
checkISBN = res
END Namespace
------------------------------------------------
..aspx page CODE
Sub ValidateISBN(s as Object, e As ServerValidateEventArgs)
Dim objValidateISBN as New ValidateISBN
lblResult.text = objValidateISBN.ValidateISBN(e.value)
END Sub
Sub Button_Click(s as Object, e as EventArgs)
IF IsValid THEN lblResult.text = "a"
IF NOT IsValid THEN lblResult.text = "b"
END Sub
----------------------------------------
The problem I am having is that the text in lblResult is not b when I
input an invalid ISBN. If res = TRUE then it is valid and if res =
FALSE then the ISBN is invalid. I don't know how to pass the value of
res from the Business object to the .aspx page. I imported the same
namespace so I know that isn't the problem. Any suggestions?