Board index » Visual Studio » Calculation Problem

Calculation Problem

Visual Studio226
I am having problems with the following:



I have a text box for a user to enter data. I have a 'calculate' button.

When a user clicks the calculate button, I need the following code to be

processed:



-verify that the user entered numbers of a specific range into that text box

(1-100)

-verify that the number is greater than 0

-verify that it was a number that was entered using the IsNumeric function

-if all is true and good, then I need to pass the data the user entered to

another variable called idb1OutOf1.



How do I do this? txtoutof1 is the text box that the user has to enter data

into. See below - very badly written because I don't quite know how to do

this.







Private Sub cmdCalculate_Click(Index As Integer)



' Added '&' symbol in front of Calculate to create a HotKey for 'C'

' Changed the 'Default' property on cmdCalculate button to TRUE to make it

the default button

' Declare a variable for the numeric value range to test for



Dim iNumvalue As Integer

iNumvalue = 1 - 100



If frmMain.txtOutof1 =>0 And IsNumeric(iNumvalue) = True Then

iNumvalue = idb1Outof1

Else: MsgBox "Mark information missing, please re-enter.", vbOKOnly +

vbcritital, "User Error!"

End If



End Sub


-
 

Re:Calculation Problem

something like



'code start

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Button1.Click

Dim anum

anum = Convert.ToInt16(TextBox1.Text())

Select Case anum

Case 1 To 100

MsgBox("number is IN range", MsgBoxStyle.Information,

"Hello")

Case Else

MsgBox("number out of range", MsgBoxStyle.Information,

"llll")



End Select

End Sub

'code end



"Infosysca" <infosysca@yahoo.com>wrote in message

Quote
I am having problems with the following:



I have a text box for a user to enter data. I have a 'calculate' button.

When a user clicks the calculate button, I need the following code to be

processed:



-verify that the user entered numbers of a specific range into that text

box

(1-100)

-verify that the number is greater than 0

-verify that it was a number that was entered using the IsNumeric function

-if all is true and good, then I need to pass the data the user entered to

another variable called idb1OutOf1.



How do I do this? txtoutof1 is the text box that the user has to enter

data

into. See below - very badly written because I don't quite know how to do

this.







Private Sub cmdCalculate_Click(Index As Integer)



' Added '&' symbol in front of Calculate to create a HotKey for 'C'

' Changed the 'Default' property on cmdCalculate button to TRUE to make it

the default button

' Declare a variable for the numeric value range to test for



Dim iNumvalue As Integer

iNumvalue = 1 - 100



If frmMain.txtOutof1 =>0 And IsNumeric(iNumvalue) = True Then

iNumvalue = idb1Outof1

Else: MsgBox "Mark information missing, please re-enter.", vbOKOnly +

vbcritital, "User Error!"

End If



End Sub









-