Question

In: Computer Science

Visual Basic program in visual studio please Write a function that checks whether a string has...

Visual Basic program in visual studio please

Write a function that checks whether a string has a number based. Use what we learned about Asc to complete the following:

Function CheckLength (S As String) As Boolean

‘add a do loop to start at first character

‘if Ascii current character is between Asc (“0”) and Asc (“9”)

‘then we have a hit Return True

‘else check the next character

‘if loop is over, that means no hit was found Return False

End Function

Use this function in an application that allows the user to enter the string/text that should be tested by your CheckLength function.

Please submit your completed application.

Solutions

Expert Solution

Dear Student ,

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

Here a new Windows Forms Application in VB is created using Visual Studio 2017 with name "StringCheckApp".This application contains a form with name "Form1.vb".Below are the files associated with form1.

1.Form1.vb[Design]

2.Form1.cs

Public Class Form1 'VB class
'Button click
Private Sub btnCheckString_Click(sender As Object, e As EventArgs) Handles btnCheckString.Click
'taking string entered by user
Dim s As String = txtString.Text
'call function
If (CheckLength(s)) Then
'when function return true , means string contains number
lblMessage.Text = s & " contains number"
Else
'when function return false
lblMessage.Text = s & " does not contains number"
End If
End Sub
'Function to check length
Function CheckLength(S As String) As Boolean
Dim i As Integer 'declaring variable
Dim ascii As Integer 'variable to store ascii value
Dim flag As Boolean 'variable used for flag
'using do While loop
Do While i < S.Length
'checking acii for fist character
ascii = Asc(S(i))
'checking value of ascii
If ascii >= Asc("0") And ascii <= Asc("9") Then
'if number found then
flag = True
Else
flag = False
End If
i = i + 1 'increment value of i
Loop
Return flag 'return flag
End Function
End Class

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

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

Screen 1 :

Screen 2:Screen when string contains number

Screen 3:When string does not contains number

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


Related Solutions

Python please Write a function that takes a string as an argument checks whether it is...
Python please Write a function that takes a string as an argument checks whether it is a palindrome. A palindrome is a word that is the same spelt forwards or backwards. Use similar naming style e.g. name_pal. E.g. If we call the function as abc_pal(‘jason’) we should get FALSE and if we call it a abc_pal(‘pop’) we should get TRUE. Hint: define your function as abc_pal(str). This indicates that string will be passed. Next create two empty lists L1=[] and...
Visual Studio Basic 1: Which string function you will be likely using to search for a...
Visual Studio Basic 1: Which string function you will be likely using to search for a certain pattern in a string? Describe your answer. 2: If you are to find the occurrence of 4-letter string “abcd” regardless of its case combinations, such as “AbCd”, “ABCd” and etc, in a long string, what would you do? Describe your answer.
String Manipulator Write a program to manipulate strings. (Visual Studio C++) In this program take a...
String Manipulator Write a program to manipulate strings. (Visual Studio C++) In this program take a whole paragraph with punctuations (up to 500 letters) either input from user, initialize or read from file and provide following functionalities within a class: a)   Declare class Paragraph_Analysis b)   Member Function: SearchWord (to search for a particular word) c)   Member Function: SearchLetter (to search for a particular letter) d)   Member Function: WordCount (to count total words) e)   Member Function: LetterCount (ONLY to count all...
Write a function that takes a string as an argument checks whether it is a palindrome....
Write a function that takes a string as an argument checks whether it is a palindrome. A palindrome is a word that is the same spelt forwards or backwards. Use similar naming style e.g. name_pal. E.g. If we call the function as abc_pal(‘jason’) we should get FALSE and if we call it a abc_pal(‘pop’) we should get TRUE. Hint: define your function as abc_pal(str). This indicates that string will be passed. Next create two empty lists L1=[] and L2=[] ....
6. Write a Python function that checks whether a passed string is palindrome or not. Note:-A...
6. Write a Python function that checks whether a passed string is palindrome or not. Note:-A palindrome is a word, phrase, or sequence that reads the same backward as forward . Some examples you may try: “madam” redder “race car” Eva, Can I Stab Bats In A Cave? If the argument passed is not a string, invoke an exception or an assertion and state in a comment which one you have chosen and why.
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings in locations str1 and str2. Initialize str1 to Computer and initialize str2 to Compater. Assume Str1 holds the correct spelling and str2 may have an incorrect spelling. Use string instructions to check if str2 is correct and if not correct the mistake in str2.
Please write in x86 Assembly language on Visual Studio. IRVINE32 Write a program to copy one...
Please write in x86 Assembly language on Visual Studio. IRVINE32 Write a program to copy one array of size 24 to another array of size 24 using string instructions. Write 3 versions of this code. One code must copy byte at a time. One code must copy word at a time and one code must copy double word at a time. Cut and paste the array in memory to show your code is working.
Write a function which takes two words as string arguments and checks whether they are anagrams.
Write a function which takes two words as string arguments and checks whether they are anagrams.
Write a function which takes two words as string arguments and checks whether they are anagrams...
Write a function which takes two words as string arguments and checks whether they are anagrams NB: Please use spider in anaconda(python) and include a picture of the code
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You will be simulating an ATM machine as much as possible Pretend you have an initial deposit of 1000.00. You will Prompt the user with a Main menu: Enter 1 to deposit Enter 2 to Withdraw Enter 3 to Print Balance Enter 4 to quit When the user enters 1 in the main menu, your program will prompt the user to enter the deposit amount....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT