Use Of MID And INSTR In .net?

Oct 23, 2009

i have a string that looks like this "Patient Name, Doc Name, Patient ID, something else"i want to extract each one of these and put it in a variable. such that var1 will equal "Patient Name" var2 will equal "Doc name" etc.. using instr and mid. what is the best way to do it?

View 3 Replies


ADVERTISEMENT

.net - Using Instr When String Is Nothing

Jul 29, 2009

I have the following condition

If InStr("a,b,c", stringA) > 0 OrElse (InStr("y,z", stringB) > 0 AndAlso value = 0) Then
endif

COndition 1 is false so i check for condition 2 that is "(InStr("y,z", stringB) > 0 AndAlso value = 0) "

What puzzles me is that when stringB is nothing it still falls into the if condition and executes the code.

On first look it would seem that when stringB is nothing condition2 would fail and as a result would not fall into the if condition.

View 1 Replies

Difference Between Instr And Contains?

Dec 8, 2009

for determining whether a string of data contains certain text, which is more efficient? I have read elsewhere that there is somewhat of a consensus to avoid legacy functions, since they may or may not be available in future versions.However, trying to use the contains method (or indexof equivalent of Instr) is causing me problems, I think, because I am having trouble performing a case-insensitive search.

I am trying to be efficient and functional in my code. I am reading an INI file, and I have preloaded the contents of the file into a String variable, for 2 reasons. 1) If I can test if a certain section exists in the code, I can avoid attempting to read a section of empty data (the INI reader class I have chosen returns the value or an empty string for a given request). More importantly, 2) I have created a data field that is not INI compliant (at least not to the API?) as it is a data field that can contain an arbitrary (unlimited?) amount of data which is a hex-encoded representation of serialized byte data. I need to be able to determine if this value exists in the file and retrieve it using normal string manipulation, since the INI handler will not pass strings longer than 256Chr.

So, the problem I am having is getting "strFileContents.Contains("data=")" to return true in the case where the file contains "Data=". This could be data=, DATA=, DaTa=, etc.Instr has the option "CompareMethod.Text" which, I believe, does a case insensitive text search. What is the equivalent for "Contains"?

View 5 Replies

Element Id's Are All Different / Instr

Mar 12, 2009

I am developing a twitter application. I can add, delete a user but now need to load the users follower page and then add the followers. the problem is the element id's are all different. I have tried the following,, loading the html into a text box and trying to read it using instr. but could not get the instr to parse the element id which looks something like this

[Code]....

View 8 Replies

How To Use RegEx Expression With InSTR

Jan 13, 2011

I'm looking to do is scrub an html file for anything that resembles an IP address or any set of numbers for that matter. Normally what I would do is just using things like string.split to split out the html around areas that I want to search. What I am looking to do is be able to essentially search a large amount of characters for anything that matches this reg ex pattern.

Dim pattern As String = "^(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5]):(d{1,4}|[0-5]dddd|[0-5]dddd|6[0-4]ddd|65[0-4]dd|655[0-2]d|6553[0-5])$"

View 1 Replies

InStr' Is A Namespace And Cannot Be Used As An Expression?

Oct 24, 2010

'InStr' is a namespace and cannot be used as an expression.Dim FirstString As String = "me@me.com"

Dim SecondString As String = "@"Dim position As Integer position = InStr(FirstString, SecondString)
If position = 0 Then MsgBox("Not a Valid email address: There was No @ Sign") End If

View 1 Replies

Using A Variable As String 2 In InStr?

Aug 16, 2011

Is it possible to use a string for string 2? cuz whenever i tried it would return a 0 instead of the position of the string. however when i hard code the string into the code it works

View 7 Replies

Use Of Mid(), Instr(), LBound(), UBound() Not Recommended?

Sep 28, 2009

I come from a C# background but am now working mostly with VB.Net. It seems to me that the above functions (and others - eg. UCase, LCase) etc. are carryovers from VB6 and before. Is the use of these functions frowned upon in VB.Net, or does it purely come down to personal preference?

View 4 Replies

Using InStr To Replace A Character From A String

Jan 21, 2011

What i am trying to do is take a character (which is going to be into a variable by user input) and search a string for this character, and save the positions of all character found and then change the same position of these characters in another string for the character that the user inputs. In other words, like a guess a word game. User tryes a guess, i search the string for that letter or number, if it's there replace it on the text box of the GUi, if not save it in another variable as a character that has been tried already, possibly an array.

View 1 Replies

VS 2008 Search Combobox Using Instr?

Jan 30, 2010

I am creating a movie player which lists movie files from various folders/subfolders in a combobox (tsFileList). I'd like to be able to enter the movie name into a textbox (txtSearch), find that text in the combobox (using instr), then automatically select the found item.I'd like to use instr as some of the items in the combobox contains full file paths.

View 3 Replies

VS 2010 Search Multiple With Instr

Nov 19, 2011

I created a code that allows me to search inside a RichTextBox...Then the code is as follows:[code]Now with the code that I use today, the MsgBox show me only the first, ie "<b> text1 </ b>" while others are not..

View 15 Replies

Manipulate Looping Serialport.readexisting And Instr?

Jun 27, 2011

i try readexisting and instr function as follow:

[code]...

View 1 Replies

Assign The Value Of The Integer Returned From The InStr Method To A Variable

Jul 21, 2009

I want to assign the value of the integer returned from the InStr method to a variable. So, If TextBox2.Text = "The Apple Pie" And TextBox1.Text = "App", I want the integer returned, which in this case would be 5, put into a variable, lets say its called 'VarString'.
So VarString (would) = 5.

[Code]...

View 6 Replies

Instr Function Handle Multiple Strings To Find?

Aug 1, 2010

I'm using this for a single value to search for.

intPositionOfApartment = InStr(StrConv(pStringToParse, vbUpperCase), "APT") Is it possible to search for more then one value such as "APT", "UNIT" ?

If yes please show me an example of how it should be coded.

View 4 Replies

Search For New Line Position In A String Variable Using InStr

Aug 7, 2009

I have an application in VB.NET which gets string data from the database. This string has data which looks as below:

"This is the update: I have an issue with the application"

I need only part of the data, that comes after the new line i.e. "I have an issue with the application".

For this I am trying to search the position using InStr where the string has data in a new line. I tried many options, but they don't work.

I used "vbCrLf", Chr(13), "
", "
", "<br/>", Environment.NewLine, but none of them work.

How can I get the data I need?

View 4 Replies

VS 2008 Extracting Text From Comma Separated Data Using Mid And Instr

Jan 23, 2011

I'm brand new to visual basic and I've been given an exercise to extract data from a text file. I can get the lines of data to read in and can get the names out using the following code. How can I extract the department i.e. sales and finance also using the mid and instr functions? I also need to be able to list list the people by department using a dropdown combo box.

[Code]...

View 3 Replies

Storing Multiple Words As One Variable To Use Instr() To See If Any Of It's Variable Words Are In The Text?

Jan 26, 2012

other than GML (Yoyogames.com Game Maker Language), I am new to the coding world. The only "major" project I have completed using VB is a computer calculator that exactly mimics the capabilities of Windows 7's calculator. Yesterday, I began a Chatbot program for my girlfriend. Lol. I have used the instr() function to answer most of the questions or answers which are typed into the textbox1. I find this extremely troublesome because when using the instr() function you cannot say instr(textbox1.

Public Class Form1
Dim fos As String = "Foster: "
Dim ash As String = "Ashley: "

[code].....

View 8 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved