Question

In: Computer Science

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.

Solutions

Expert Solution

Strings.StrComp(String, String, CompareMethod) Method

Returns -1, 0, or 1, based on the result of a string comparison.

C#

public static int StrComp (string String1, string String2, Microsoft.VisualBasic.CompareMethod Compare = Microsoft.VisualBasic.CompareMethod.Binary);

Parameters

String1

String

Required. Any valid String expression.

String2

String

Required. Any valid String expression.

Compare

CompareMethod

Optional. Specifies the type of string comparison. If Compare is omitted, the Option Compare setting determines the type of comparison.

Returns

Int32

The StrComp function has the following return values.

TABLE 1
If StrComp returns
String1 sorts ahead of String2 -1
String1 is equal to String2 0
String1 sorts after String2 1

Exceptions

ArgumentException

Compare value is not valid.

Examples

This example uses the StrComp function to return the results of a string comparison.

VB

' Defines variables. Dim testStr1 As String = "ABCD" Dim testStr2 As String = "abcd" Dim testComp As Integer ' The two strings sort equally. Returns 0. testComp = StrComp(testStr1, testStr2, CompareMethod.Text) ' testStr1 sorts before testStr2. Returns -1. testComp = StrComp(testStr1, testStr2, CompareMethod.Binary) ' testStr2 sorts after testStr1. Returns 1. testComp = StrComp(testStr2, testStr1, CompareMethod.Binary) 

Remarks

The strings are compared by alphanumeric sort values beginning with the first character. For further information on binary comparisons, textual comparisons, and sort order, see Option Compare Statement.

The Compare argument settings are:

TABLE 2
Constant Description
Binary Performs a binary comparison, based on a sort order derived from the internal binary representations of the characters.
Text Performs a text comparison, based on a case-insensitive text sort order determined by your system's LocaleID value.

Related Solutions

Using Visual Studio Code (JavaScript) For this lab you must use a reasonable faceted search example,...
Using Visual Studio Code (JavaScript) For this lab you must use a reasonable faceted search example, each item must have at least three categorical attributes and at least one numeric attribute. Attributes such as ID, name etc do not count as categorical or numeric attributes. Exercise 1 (a) Define a class for your item that meets the above three categorical and one numeric attribute requirements. (b) Create a text file that contains at least 5 such records in CSV format....
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....
Module/Week 1 ASSIGNMENT (BASIC ELEMENTS) 1. Install Visual Studio Express 2019 for Windows Desktop (you will...
Module/Week 1 ASSIGNMENT (BASIC ELEMENTS) 1. Install Visual Studio Express 2019 for Windows Desktop (you will need to create a free Microsoft account as part of this process, if you do not already have one). LINK - https://www.visualstudio.com/downloads/ Instructions for installation can be found in the Reading & Study folder of Module/Week 1. 2. Create a new empty project in Visual Studio (VS) called “Hello World,” and then create a new .cpp file called HelloWorld. Into your HelloWorld.cpp file, copy...
Implement a substring search function which searches a string for a given keyword. The function should...
Implement a substring search function which searches a string for a given keyword. The function should return a pointer to the address of the first character of the substring within the original string, if it exists. If the substring is not found within the string, return NULL. If the input is found, print "Key found." otherwise print "Key not found." Your program’s input and output should match what is seen in the example run. • You may only use stdio.h....
Create a Visual Studio console project using c++ void lowerToUpper(std::string & sentence) that iterates over all...
Create a Visual Studio console project using c++ void lowerToUpper(std::string & sentence) that iterates over all characters in the sentence argument. Any lowercase letter should be converted to uppercase. This can be done by including <cctype> and testing each character in sentence with the islower() function. If islower(sentence[i]) returns true then sentence[i] should be replaced with toupper(sentence[i]). The main() function should assign "Hello how are you doing?" to sentence, call lowerToUpper(sentence), and use an if statement to check the new...
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...
In Assembly Language (Visual Studio 2017), create a procedure that generates a random string of Length...
In Assembly Language (Visual Studio 2017), create a procedure that generates a random string of Length L, containing all capital letters. When calling the procedure, pass the value of L in EAX, and pass a pointer to an array of byte that will hold the random string. Write a test program that calls your procedure 20 times and displays the strings in the console window. In your program, the random string size shall be preset as a constant. Please include...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax Application 1.1 Problem Statement Due to upcoming end of financial year, you are being called in to write a program which will read in a file and produce reports as outlined. Inputs: The input file called IncomeRecord.txt contains a list of Annual income records of employees in a firm. Each record is on a single line and the fields are separated by spaces. The...
Answer the questions below as indicated. Note that you have to complete these using Visual Studio...
Answer the questions below as indicated. Note that you have to complete these using Visual Studio 2019. Upload the source code (.cpp) of your applications. Upload a separate (.cpp) file for each question. 1-Create a C++ program which adds two numbers and displays the sum. 2-Create a C++ program which calculates and displays the area of a rectangle. 3-Create a C++ program which calculates and displays the average of four numbers.. 4-Complete questions 3 of the chapter 3 Programming Exercises...
Create an ASP.Net Website using Visual Studio with Visual Basic.Net: Create a simple calculator that has...
Create an ASP.Net Website using Visual Studio with Visual Basic.Net: Create a simple calculator that has 3 text boxes: 2 of them to enter numbers, the 3rd one displays the results Create 4 buttons to add, subtract, multiply, and divide Prevent the user from entering text in the number fields Display a message indicating “cannot divide by” when the user click “/” and there is a zero the in the second box Create two additional buttons: - One to store...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT