Help With Business Objects

S

Sparky Arbuckle

How do I successfully pass a value my Business object (.vb) to my .aspx
page? Right now I am trying to use this:

Imports System
Imports Microsoft.VisualBasic

Namespace ASDFComponents

Public Class ValidateISBN

Public res As Boolean
Public checkISBN as string
Public Number As String
Public CheckDigit As String
Public CheckValue As Integer
Public CheckSum As Integer
Public i As Byte
Public Cnt As Byte

Public Function ValidateISBN(strISBN as string)

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

RETURN res

END Function

END Class

END Namespace


--------------------

This is how I try and call that:

Sub Button_Click(s as Object, e as EventArgs)

Dim objValidateISBN as New ValidateISBN
objValidateISBN.strISBN = tbISBNNumber.text
lblResult.text = objValidateISBN.ValidateISBN(e.Value)
END Sub

When I call this in my .aspx page I get the following error:

Compiler Error Message: BC30456: 'strISBN' is not a member of
'ASDFComponents.ValidateISBN'.


Does anyone see what exactly it is that I'm doing wrong? I've uploaded
a .dll file that I compiled into my /bin directory. I'm stuck!
 
S

Steven Berkovitz

There is no variable or property named strISBN.

Your code should look like:

Sub Button_Click(s as Object, e as EventArgs)

Dim objValidateISBN as New ValidateISBN

lblResult.text = objValidateISBN.ValidateISBN(tbISBNNumber.Text)
END Sub
 
G

Guest

hi sparky

u hav'nt used return type boolean in ur function
try with this: Public Function ValidateISBN(strISBN as string) as boolean
 
G

Guest

Sparky Arbuckle said:
How do I successfully pass a value my Business object (.vb) to my .aspx
page? Right now I am trying to use this:

Imports System
Imports Microsoft.VisualBasic

Namespace ASDFComponents

Public Class ValidateISBN

Public res As Boolean
Public checkISBN as string
Public Number As String
Public CheckDigit As String
Public CheckValue As Integer
Public CheckSum As Integer
Public i As Byte
Public Cnt As Byte

Public Function ValidateISBN(strISBN as string)

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

RETURN res

END Function

END Class

END Namespace


--------------------

This is how I try and call that:

Sub Button_Click(s as Object, e as EventArgs)

Dim objValidateISBN as New ValidateISBN
objValidateISBN.strISBN = tbISBNNumber.text
lblResult.text = objValidateISBN.ValidateISBN(e.Value)
END Sub

When I call this in my .aspx page I get the following error:

Compiler Error Message: BC30456: 'strISBN' is not a member of
'ASDFComponents.ValidateISBN'.


Does anyone see what exactly it is that I'm doing wrong? I've uploaded
a .dll file that I compiled into my /bin directory. I'm stuck!
 
G

Guest

hi sparky ,
try with this modified code:

..........................................................................................................................
Imports System
Imports Microsoft.VisualBasic

Namespace ASDFComponents

Public Class ValidateISBN

Public res As Boolean
Public checkISBN as string
Public Number As String
Public CheckDigit As String
Public CheckValue As Integer
Public CheckSum As Integer
Public i As Byte
Public Cnt As Byte

Public Function ValidateISBN(strISBN as string) as boolean
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

RETURN res

END Function

END Class

END Namespace


--------------------

and then modify:

imports ASDFComponents

Sub Button_Click(s as Object, e as EventArgs)

Dim objValidateISBN as New ValidateISBN
objValidateISBN( tbISBNNumber.text)
lblResult.text = objValidateISBN.ValidateISBN(e.Value)
END Sub
...............................................
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top