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

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...
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...
MUST BE DONE IN C++ Use qsort( ) function in Visual Studio to sort the following...
MUST BE DONE IN C++ Use qsort( ) function in Visual Studio to sort the following three arrays: int array1 [] = { 3, 4, 2, 1, 7}; float array2 [] = {0.3, 0.1, 5.5, 4.3, 7.8}; char array3 [] = {‘c’, ‘d’, ‘a’, ‘b’, ‘f’};                                     Develop a driver function to print out the sorted results and put the screenshot into the word document. Note that you have to use qsort( ) provided by Visual Studio. What is the...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some time and still can't quite figure it out. I'm creating an app that has 2 textboxes, 1 for inputting customer name, and the second for entering the number of tickets the customer wants to purchase. There are 3 listboxes, the first with the days of the week, the second with 4 different theaters, and the third listbox is to display the customer name, number...
Using Python #Write a function called after_second that accepts two #arguments: a target string to search,...
Using Python #Write a function called after_second that accepts two #arguments: a target string to search, and string to search #for. The function should return everything in the first #string *after* the *second* occurrence of the search term. #You can assume there will always be at least two #occurrences of the search term in the first string. # #For example: # after_second("11223344554321", "3") -> 44554321 # #The search term "3" appears at indices 4 and 5. So, this #returns everything...
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that...
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that prompts the user to select a type of coffee she likes and 2) returns the object of what she selected to the console. #include "stdafx.h" #include <iostream> using namespace std; // Product from which the concrete products will inherit from class Coffee { protected:    char _type[15]; public:    Coffee()    {    }    char *getType()    {        return _type;   ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT