Question

In: Computer Science

Dim Digit1 As Double Dim Digit2 As Double Dim Digit3 As Double Dim Digit4 As Double...

Dim Digit1 As Double Dim Digit2 As Double Dim Digit3 As Double Dim Digit4 As Double Dim Digit5 As Double Digit1 = ((txtboxInput.Text) Mod 100000) / 10000 Digit2 = ((txtboxInput.Text) Mod 10000) / 1000 Digit3 = ((txtboxInput.Text) Mod 1000) / 100 Digit4 = ((txtboxInput.Text) Mod 100) / 10 Digit5 = (txtboxInput.Text Mod 10) lblDigit1.Text = Math.Truncate(Digit1) lblDigit2.Text = Math.Truncate(Digit2) lblDigit3.Text = Math.Truncate(Digit3) lblDigit4.Text = Math.Truncate(Digit4) lblDigit5.Text = Math.Truncate(Digit5) End Sub Private Sub txtboxInput_TextChanged(sender As Object, e As EventArgs) Handles txtboxInput.TextChanged lblDigit1.Text = "" lblDigit2.Text = "" lblDigit3.Text = "" lblDigit4.Text = "" lblDigit5.Text = ""

I have to put were letters can be put in textbox. Its throwing an exception on Mod. I cant figure out what I need to do so when you input letters it does not throw error.

Solutions

Expert Solution

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

NOTE :This application is designed for demonstration purpose only make changes as per requirement.

Here a new Windows Forms Application in VB is created using Visual Studio.Below are the forms

1.Form1.vb[Design]

2.Form1.vb

'VB class
Public Class Form1
'When text in the textbox is changed then clear labels
Private Sub txtboxInput_TextChanged(sender As Object, e As EventArgs) Handles txtboxInput.TextChanged
lblDigit1.Text = ""
lblDigit2.Text = ""
lblDigit3.Text = ""
lblDigit4.Text = ""
lblDigit5.Text = ""
End Sub
'Button click event
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Digit1 As Double
Dim Digit2 As Double
Dim Digit3 As Double
Dim Digit4 As Double
Dim Digit5 As Double
Dim Digit As Double
'checking number using TryParse
If (Integer.TryParse(txtboxInput.Text, Digit)) Then
'if numeric number is entered then do this
Digit1 = ((txtboxInput.Text) Mod 100000) / 10000
Digit2 = ((txtboxInput.Text) Mod 10000) / 1000
Digit3 = ((txtboxInput.Text) Mod 1000) / 100
Digit4 = ((txtboxInput.Text) Mod 100) / 10
Digit5 = (txtboxInput.Text Mod 10)
lblDigit1.Text = Math.Truncate(Digit1)
lblDigit2.Text = Math.Truncate(Digit2)
lblDigit3.Text = Math.Truncate(Digit3)
lblDigit4.Text = Math.Truncate(Digit4)
lblDigit5.Text = Math.Truncate(Digit5)
Else
'When non numeric number is entered
MessageBox.Show("No alphabets are allowed")
End If


End Sub
End Class

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :

Screen 2:Screen when non numeric numbers are entered

Screen 3:Screen when numeric number is entered

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

Let U be a subspace of V . Prove that dim U ⊥ = dim V...
Let U be a subspace of V . Prove that dim U ⊥ = dim V −dim U.
Suppose ? is a finite-dimensional with dim ? > 1 and ? ∈ ℒ(?). Prove that...
Suppose ? is a finite-dimensional with dim ? > 1 and ? ∈ ℒ(?). Prove that {?(?)|? ∈ ?[?]} ≠ ℒ(?).
a. In the statement Dim newStudent As Student, which is the class and which is the...
a. In the statement Dim newStudent As Student, which is the class and which is the object variable? b. Look at the following problem description and identify the potential classes. We need to keep a list of customers and record our business transactions with them. Each time a customer purchases a product, an order is filled out. Each order shows a list of items kept in our central warehouse.
Let ? be an eigenvalue of a matrix A. Explain why dim(?) ? 1
Let ? be an eigenvalue of a matrix A. Explain why dim(?) ? 1
double maxArea(Rectangle a, Rectangle b, Rectangle c) {     double width;     double length;     double...
double maxArea(Rectangle a, Rectangle b, Rectangle c) {     double width;     double length;     double area = 0;     area = width * length;     cout << "\n***maxArea called" << endl;          cout << "***       rectangleCount = " << Rectangle::rectangleCount << endl << endl;    } Compete this code to find the maximum area of rectangle between a,b,c
Circle Radius: double Circle() Circle(newRadius: double) getArea(): double setRadius(newRadius: double): void getRadius(): double After creating the...
Circle Radius: double Circle() Circle(newRadius: double) getArea(): double setRadius(newRadius: double): void getRadius(): double After creating the Circle class, you should test this class from the main() method by passing objects of this class to a method “ public static void printAreas(Circle c, int times)” You should display the area of the circle object 5 times with different radii. 2 java.util.Random +Random() +Random(seed: long) +nextInt(): int +nextInt(n: int): int +nextLong(): long +nextDouble(): double +nextFloat(): float +nextBoolean(): boolean Constructs a Random object...
Let T be an operator on a finite-dimensional complex vector space V, and suppose that dim...
Let T be an operator on a finite-dimensional complex vector space V, and suppose that dim Null T = 3, dimNullT2 =6. Prove that T does not have a square root; i.e. there does not exist any S ∈ L (V) such that S2 = T.
Explain why the functions diag, dim, length, and names can be as- signed new values (as...
Explain why the functions diag, dim, length, and names can be as- signed new values (as in diag(m)=pi). Explain why (or why not) they are useful.
class Function {     public:     virtual double compute(double value) = 0;     virtual double differenciate(double value) = 0;...
class Function {     public:     virtual double compute(double value) = 0;     virtual double differenciate(double value) = 0;     virtual double integrate(double value) = 0; }; class Sine : public Function {     public:     double compute(double value); // compute sin(x) for a given x     double differenciate(double value); // compute derivative sin'(x) for a given x     double integrate(double value); // integrate sin(x) for a given x }; class Tangent : public Function {     public:     double compute(double value); // compute tan(x) for a given x     double...
Dim sum bonds are: a. bonds issued by non-Chinese companies in Chinese yuan in mainland China...
Dim sum bonds are: a. bonds issued by non-Chinese companies in Chinese yuan in mainland China b. bonds issued by non-Chinese companies in dollars in mainland China c. bonds issued by Chinese companies in Chinese yuan in Brussels d. bonds issued by a company (Chinese or non-Chinese) in Chinese yuan outside China
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT