.net - IndexOf Returns Always Zero?
Sep 11, 2010
Could someone point me why the IndexOf returns always zero in the following text?
Dim Str as string = "<p><img class=floatLeft width="330"src="http://www.com"></p><p>"
Dim Idx as integer = Str.IndexOf("<p>")
Is there any other way, of getting the index?
View 1 Replies
ADVERTISEMENT
Sep 2, 2009
I'm working on some code that was developed by the previous developer of an application and I don't understand why he used a certain syntax for IndexOf().This is the code (MyString is just an example of the string being searched for): [code] I can't seem to find any documentation for this unless it's inside of a loop where the number after the comma is incremented.
View 3 Replies
Apr 1, 2012
I have a text label, split half-and-half with a "/".label1.text = "I like dogs/I like cats"This will not be the same text (and not the same textlength)every times. I need to delete everything before the "/" with only a button. (for example, delete "I like dogs")
View 6 Replies
Jan 7, 2011
I'm just extracting some very small text from a bigger text file. So, suppose I'm getting a dl link from a " dl link here " tag, there are multiple download links and the way i'm 'extracting' the download link from there uses the indexof method. There are multiple download links, so how would I get the next indexof?
View 2 Replies
Oct 9, 2011
substring and the indexOf method
I have this problem that I'm going in circles on. The error message is "no accessible IndexOf can be called with these arguments."
My professor said that "to search for the string Los Angeles and substring will return it from the textbox, but it needs to know what position to start returning a word at, and that is where the IndexOf comes in." Does that mean substring and IndexOf are used together? That's what I did and may be the problem. Here's the code:
Private Sub btnOrder_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnOrder.Click
'Declare variables
[Code]....
View 1 Replies
Feb 23, 2012
I'm filter my Listview with cboMonth my format date MM/dd/yyyy..Now I want change my format date dd-MM-yyyy.[code]
View 11 Replies
Feb 21, 2009
I have a string array in the form [code] The above obviously doesn't work since it's an array. Is there a similar method for the string array.
View 1 Replies
Sep 8, 2010
How would I find the index of an item in the a string array following code:
Dim arrayofitems() as String
Dim itemindex as UInteger
itemindex = arrayofitems.IndexOf("item test")
Dim itemname as String = arrayofitems(itemindex)
I'd like to know how I would find the index of an item in a string array. (All of the items are lowercase, so case shouldn't matter.)
View 3 Replies
Oct 7, 2011
My assignment in Visual Basic 2010 is to build a order form that has two text boxes, one for the name and the other for the address. And we're suppose to use the IndexOf method on the address. I understand that IndexOf returns the position of a character and the number of characters. What would be the purpose of using the IndexOf method on the address in this instance? I don't understand what I would be searching for when the user types in it's address that's going to be numbers and string characters. I think I understand what the IndexOf method does, somewhat, but why and what would I use it to achieve?
View 3 Replies
Mar 11, 2009
I'm having a bit of trouble trying to iterate or search through my array (or structure).I am reading in some values from a file, and populating my array.Then, I need to search to compare to one of the values in my array.[code]any pointers? should I use something else instead of arrays / structures ?
View 4 Replies
Sep 29, 2009
I have created an object hierarchy with nested generic listof() structures. I have created a treeview to match and graphically show the structure. I needed a way to show a property box of an object represented by the selected node on the treeview. So, I gave each of my objects a NodeIndex property, in which I would store the treeview.indexof(node) result, as shown below:
For Each oObject In oJob.ObjectListOfCollection
tnode = New TreeNode(oObject.Name)
Treeview.Nodes.Add(tnode)
[code].....
View 13 Replies
Jul 28, 2009
What would be the simplest way to find the n-th position of delimiter in a string.For example, say, I have a string variable called FullFilePath that contains the path of a file, like, C:SourceFiles<mthyr><subject><filename>.txt From this, I would like to extract out mthyr, subject, and filename, using the delimiter, "".
I was hoping string.IndexOf would let me find the n-th position of the delimiter "", in which case I can use the result to do a string.Substring. But it looks like IndexOf only finds the first occurence of a certain string, which means I would have to interate this somehow to look for the n-th occurence.
Or is there another method that will help me do this more efficiently.
View 2 Replies
Oct 2, 2009
Can anyone give a good explanation of how the indexof method works and what is meant by "Index" ?
View 3 Replies
May 1, 2011
I have 10 lines of array that are first name space last name space zip code. All the zip codes start with different numbers. Is there a way to replace the #1 in the indexof below so that it searches for any number character instead?
'open file
inFile = IO.File.OpenText("Names.txt")
'process the loop instruct until end of file
intSubscript = 0
[code].....
View 1 Replies
Jun 30, 2009
i want index of the first value in a string Without calling IndexOf.
Like, " I am going" and my search value is "am"
so it should give me index value as "2".
View 8 Replies
May 1, 2011
How do I use the Indexof Method to search for an Index a number? The number will be different on each line of the file. Each array has a name and a different zip code. I want to tell it to search for the first number in the line. Everything before that index will be first name, last name, and then zip code.
[Code]...
View 1 Replies
Oct 11, 2009
I have a string with 60000+ characters. I look for informations inside the string in a sequentially order. Every time I found a information I delete whatever is behind that information. In other words I reduce the size of the string every time I find something, and I do this using IndexOf and Remove, much like this:
vb.net Str = Str.Remove(0, Str.IndexOf("MyInfo"))
This can be quite heavy on the processor. So my question is it faster to look the informations using Regex or it would be about the same?
View 5 Replies
Feb 12, 2012
As i described below code i am trying to find the the similar class from the ClassArray using the indexof method. How can we invoke name property inside the indexof method
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
[Code].....
View 3 Replies
Mar 15, 2012
I have loaded a list of values from a mysql database into a CheckedListBox and want to be able to select them to eb used in a query. The CheckedListBox shows the data as table_name.attribute_name, and when an item is selected I try to break up the two values by using a substring, like this:
Dim strTable As String = clbFields.GetItemText(clbFields.SelectedItem.Substring(0, clbFields.SelectedItem.IndexOf("."))).ToString
Dim strAttribute As String = clbFields.GetItemText(clbFields.SelectedItem).ToString
Whenever I select an item though it comes up with the error "Public member 'IndexOf' on type 'DataRowView' not found." What needs to be changed?
View 2 Replies
May 20, 2012
I'm having trouble with a more complex program, so I've created a simple program to highlight my issue (see code block below). When I declare a Collection generically (like I have below) and try to call IndexOf, I get the following compiler error:
'IndexOf' is not a member of 'Microsoft.VisualBasic.Collection'. (BC30456)
If I instead declare my Collection as a collection of strings (Public mycollection As New Collection(Of String)), I then have access to the usual methods, but the .Add method then only allows a single string to be passed to it. This means that I can't use a key, which seems to be the point of a collection. Is there any way to have a general, keyed collection that can use IndexOf?
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
[code]....
View 14 Replies
Sep 17, 2010
I have a program that is reading an Excel (xlsx) file and I am trying to take the data found in one of the cells and split it based upon the '@' symbol inside that cell. Here's an example: value in cell is "XXX @ YYY" I declare 3 strings (strOriginal, strA, strH) strOriginal is the value from the cell ("XXX @ YYY") then my code is supposed to split up the values in the Original string based upon that '@' symbol.So when my code is done, strA should = 'XXX' and strH should = 'YYY'.
Here is my code
strOriginal = dtbExcelData.Rows(0).Item(0).ToString
y = strOriginal.IndexOf("@")
strA = strOriginal.Substring(0, y - 1)
[code]....
For some unknown reason, the y integer (in this case, it is '4') changes to a random number (it has changed to 44, 61, 124) and causes the error "Error with Excel file: Index and length must refer to a location within the string. Parameter name: length" to occur.I understand why the error occurs (my y integer is not staying at 4)...I just don't understand why that y integer is changing numbers when it should remain as the indexof the '@' symbol. I'm looking for any suggestions on how to pull out the data after the space after the '@' symbol (the 'YYY' portion of 'XXX @ YYY'). Also sometimes the 'YYY' is only 'YY' as well.
View 4 Replies
Jun 24, 2010
I have some code which gets child items for a menu via the GetChildren function which takes a list of menuData: Dim builtMenu As New List(Of MenuData)(_rawData.FindAll(Function(item) item.GroupingID = 0))
For Each menuData As MenuData In builtMenu
If menuData.Children IsNot Nothing Then
menuData.Children.AddRange(GetChildren(menuData))
End If
Next
If I check if menudata.children isnot nothing, it always is nothing because the GetChildren function is yet to run (providing the child items, which do exist). If I remove this check and just have this code:
Dim builtMenu As New List(Of MenuData)(_rawData.FindAll(Function(item) item.GroupingID = 0))
For Each menuData As MenuData In builtMenu
menuData.Children.AddRange(GetChildren(menuData))
Next
Then I am presented with a Object reference not set to an instance of an object error on menuData.Children.AddRange(GetChildren(menuData))
View 1 Replies
Nov 9, 2011
What if we wanted seconded index of? ' example this is a long message after a few spaces. If we wanted to split this message from the second index of " " (space) returned result long message after a few spaces
View 3 Replies
Jun 28, 2010
I am a vb newbie having some trouble with an assignment. A user enters a letter into a text box, and the output must make the letter uppercase and tell what position the letter is at in the sentence "The quick brown fox jumps over a lazy dog."
Here is my
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
[CODE]...............
This is what comes out: "A first occurs in position -1". Everything comes out except the position is always displayed as -1.
View 4 Replies
Dec 1, 2011
What I am doing is iterating through all the groups that belong to the top group (Generic reports). Then I take advantage of the GroupPrincipal.GetMembers(True) which will recurse through a given group name. I test to see if the user exits under that group and if true I put the group name in an arraylist.
I use the for each principal in GroupPrincipal.GetMembers to loop through each returned user to see if they exist.
Is there a way to put all the returned users Principal.Name from a given group in GroupPrincipal.GetMembers into an ArrayList? This would allow me to to use Arraylist1.IndexOf to search for user. Which would be much faster then iterating through a returned list using the for each construct.
Sub RetAllMbrs(strUser As String)
Dim oPC As PrincipalContext = GetPrincipalContext() '<- this is function somewhere else in the code
[Code].....
View 1 Replies
Jul 1, 2011
Would the world of strings be better if stringbuilder had IndexOf?
View 2 Replies
Nov 16, 2010
i have a datatable with column "prices" and i displeay the column values in a listbox and i sum all the values in this column and i display the sum in a label.text but when i delete one row in de listbox the sum returns a zero value.[code]
View 2 Replies
May 17, 2011
[Code]...
I always get {} as answer. What's wrong?
View 1 Replies
May 9, 2011
I'm trying to create a function that would return a PDF document. Something like this:
Function GetPDF(ByVal DirectoryPath as String) as PDF
Return DirectoryPath
End Function
View 1 Replies
Apr 12, 2011
I am using Sql Server 2005 and Vb Studios 2010 on a .net Framework of 4.0. I am trying to get the exact number of rows from a database and populate a datatable then have a label show the number of rows.
Dim comm2 = db.selectcommand(db.conn, "*", "Tablename", " columnname = '" & Session(sessionvariable) & "' AND columnname = 'Unread '")
Dim sqlda2 As New SqlDataAdapter(comm2)
[Code]....
View 4 Replies