Link To XML - Determine If An Element Exists In A List?
Apr 27, 2012
I am working with LINQ to XML in VB (although answers in C# are great, too). First off- my code works, so this is not critical. However, I can't help but think that what I'm doing with conditional logic should already be doable using the LINQ query itself. Here's what I've got:
'Get the Description elements in the ResultData section where the value is "Op Code"
Dim opCodes As List(Of XElement) = (From c In xdoc.Descendants("ResultData").Descendants("Description")
Where c.Value = "Op Code"[code].....
Please don't be too critical of my method of locating the sibling nodes- the XML files are produced by a third-party testing device and this is the only generic way to get the values I need. What I'm really looking for here is a better way to handle the If block.
View 1 Replies
ADVERTISEMENT
May 9, 2009
Just like the title says, I have a webbrowser and I need to determine if the element exists or not before I invoke it.
View 1 Replies
Aug 9, 2010
I'm using the coding below to determin if a certain file exists on the hdd. However there is an error on this line: If FileExists("C:myfile.txt"))="False" then msgbox "False"
it gives me the following error message:End of statement expected.
what am I doing wrong?
[Code]...
View 1 Replies
Aug 27, 2010
Below is the code that is adding a toolstripmenuitem at runtime. I do need to check elsewhere to see if it exists. What I have below is incorrect. How would I change the conditional check below?
ToolStripMenuItemFile.DropDownItems.Add("Save")
ToolStripMenuItemFile.DropDownItems(2).Click += New EventHandler(SaveFile_Click)
If ToolStripMenuItemFile.DropDownItems(2) IsNot Nothing Then
ToolStripMenuItemFile.DropDownItems(2).Text = rm.GetString("Save")
End If
View 2 Replies
May 23, 2012
Is there a way to determine if a Printer exists?I want to warn my users that a printer doesn't exist before they send reports to print.
View 4 Replies
Jun 19, 2010
Is there a way to check if an element is in the webbrowser1.document ?
I can click the button fine, IF the element is on the page, but sometimes i get to the end page, where i just have the "back" button, and no forward button.[code]...
View 1 Replies
Apr 3, 2009
My current code:
If webbrowser.document.getElementById("login")
I'm not sure what comes after it.... I've read about and it seems for JS its a simple (or similar to);
{If(document.getelementbyid("login"))
{ if true}
{if false}}
but for VB?
View 1 Replies
Sep 8, 2010
How do I check if an HTML element exists? This element will only "show" on a certain event. ex: numbers in a non-number textbox or something. I tried
If WebBrowser1.Document.GetElementsByName("ElementName")
But that won't work, because the element "is in" the HTML, even though the page doesn't show it yet.
View 4 Replies
Nov 14, 2008
I have a function in VS2008 VB.NET that creates a dataset and reads field values from that were loaded from a SQL Server 2008 database tables. The tables are from varied sources and in some cases particular column/field names are different. Some use a long name; others use a short name. I need to determine whether a short name or a long name is being used.Pseudo code:If row("ShortName") Exists then ReadDataFrom r("ShortName").ToStringElse ReadDataFrom r("LongName").ToStringEnd If
How would I determine if a particular column name exist in a dataset or datarow?
View 2 Replies
Jan 7, 2009
I wanted to create a login system that would have 3 tabs 1 for regular login, 1 for admin login and 1 for account creation. So far so good. It saves the accounts by saving them in a .urs file in the map called /Users/. However when this map does not exist it will show a error. I would want to know what code or so to put into the form_load which will make my program create the map /Users/ if it does not exist. As im not familiar with all the codes and stuff. The only thing i can come up with is
Mkdir "/Users/"
but then ofcourse it would create the folder users everytime i start the program. not i was still "Hello Worlding" a few days ago, so i really am unfamiliar with any sort of high-skilled programming which i probably dont understand.
View 2 Replies
Jan 25, 2010
I would like to check if a URL exists -- without requesting the file. The program needs to check if a PDF or Excel spreadsheet exists at a particular URL. If it does, it might want to download the file, but it should not download it every time.
I currently use the WebBrowser.Navigate method to do this, but it always downloads the file. But I don't want to actually download the .pdf or .xls file, I just want to determine if the URL exists.
View 8 Replies
Jan 10, 2010
Im just trying to determine if a website exists when i navigate my webbrowser. via messagebox.Ive tried this so far but it wont work:
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If WebBrowser1.DocumentText.Contains("Action canceled") Then
[code]....
View 13 Replies
Feb 15, 2010
I am trying to create a function that will determine if a worksheet within the active workbook exits. I have searched many web sites without any luck. Here is the coding I have currently:
HTML
Function SheetExists(ByVal sheetname As String) As Boolean
Dim oWorkbook As Excel.Workbooks
[Code]....
It errors out at Dim oWorksheet As Excel.Worksheet = oWorkbook.Sheets(sheetname).
The error message I am getting is "Object variable or With block variable not set."
View 3 Replies
Jan 20, 2011
I'm writing a rather complex VB2008 programme, To simplify the things, here is the code:
Structure strucFirst
Dim Field1 as Integer
Dim Field2 as Single
[Code]....
I'm not sure if the pseudocode above is possible in VB at all?
View 4 Replies
Feb 17, 2010
I have the name of a form in a string variable, e.g. "frmOptions". I want to:
1) get the fully qualified name of the form
2) determine if the form exists in the application
3) create an instance of the form
4) show the form
I know that using reflection I can do #3 this way, but I need to get the fully qualified form name first[code]...
View 3 Replies
Jun 28, 2011
I am trying to write a LINQ query which will return true if there are multiple objects which have a property with the same value.
Here is what I have come up with so far:
Formatters.Where(Function(f As DataModel.Formatter) _
Formatters.Select(Function(f2 As DataModel.Formatter) f2.Name.ToLower()).Contains(f.Name.ToLower())).Count > 1
However the above always returns true as long as their are more then 1 elements in the list?
View 1 Replies
Nov 12, 2009
I have a number of dropdown lists that I'm trying to chain together and they all have autopostback. How can I tell which one of the dropdown lists was the one responsibe for the autopostback?
View 1 Replies
Jun 18, 2011
I'm doing some directory work and in this directory, some of the subdirectories are symbolic links to a different location. I need to be able to determine which directly is a symlink and process them differently.
View 1 Replies
Sep 13, 2009
I need to know how to find the HTML element the mouse if hovering over such as a link so that I can open the link in a new tab, what would be an easy way of doing this?
View 3 Replies
Oct 1, 2009
I'm looping all the properties in an object via reflection:
For Each p As PropertyInfo In values.[GetType]().GetProperties()
If p.CanRead Then
'Do stuff
End If
Next
how to determine whether the property in question is a generic List(Of T)? If it is I need to loop the list itself.
I've experimented with GetType and TypeOf but have not managed to get anything working.
To clarify, I want to keep this generic. I do not want to specify the type of T, I need to loop the list items and call the ToString method on each item. T could be one of a number of different types (application specific reference types). Is it possible to do this without specifying types?
(VB.NET 2005 with .Net 2.0)
View 3 Replies
Nov 26, 2010
[Code]...
Now I find myself needing to do both Foo() and Bar() if value is "7" - is there a simple way to do this with an If condition?
[Code]...
I don't want to have to declare & initialize two lists if I can avoid it. Edit: I should have mentioned that this is a simplified example - there are actually a dozen or so CASE statements, and Foo() and Bar() are actually placeholders for quite a bit more code - it's seeing the same block of code repeated over and over that got me thinking about a better way to do it.
View 3 Replies
Dec 15, 2011
I am new to Vb.net so I will need some handholding. I have been searching everywhere but can't find what I need.I'm creating an app that has two forms.Each form has two comboboxes.The comboboxes are populated via a list and the list is populated by reading a text file for each combobox.The second form is called from the main form to modify the entries in the comboboxes. When I select the displaymember in the combobox a value corresponding to that entry is displayed in the text box.Now here is what I need.
I need to be able to append new values to the list so when focus is returned to the main form the new value is present. I'm using a combobox and a textbox on the second form as the import.The combobox is used to either select a present value to be able to modify the value in the textbox, or is used to add a new list element.
[Code]...
View 17 Replies
Jun 6, 2011
Dim myArray() As Integer = {a, b, c, d, f}[code]...
Based on the code above i would like to remove the largest and smallest element from the array list and then put it into a new array list.
View 3 Replies
Jan 6, 2010
see if an object is already in a generic List(Of T) than the way I am currently doing it? The way I do it at the moment is like so:I have a method that I call each time I want to check to see if an object exists in the list (if it already exists I do not want to add it again) and the list to check is passed in to this method along with the item that should be added to it:
[Code]...
So as you can see this function just loops through the list that was passed in and if the DisplayName property of one of the items in the list is the same as the ProgramName argument that was passed in to the method as well then it returns True to indicate that this program is already in the list.I thought about using a Predicate with the List.Find method but cant see how I would get it to work because that predicate method will not have any way of referencing the list (its a method local list, not class level)
View 5 Replies
Oct 22, 2010
Nothing on google what so ever.
Private mArryLinkEntries As List(Of String)
some timers i get a matching string in the list, so i need to remove one element[code]...
View 5 Replies
Dec 15, 2010
[code]Now how can I check if a certain employee is in the list? ie. I want to know if "John Smith" is in Employees. I see there is a .Contains method but I can't figure out how to use it on a ListIf Employees.Contains(???) Then (need to check for "John Smith" here)
View 21 Replies
Nov 3, 2011
I want to know if a string exists in the list of array ignoring case sensitivity
I have the following code working for my requirement, but its checking case sensitivity. How can use it ignoring case sensitivity...?
Dim SrtList() As String = {"abc","qwe","zxc"}
Dim chkStr As String = "abc"
If strList.contains(chkStr) Then
[Code]....
View 3 Replies
Jul 14, 2011
I've been scouring the net, and can't seem to find a solution that works.I have a page done in ASP.NET (in VB) that has a drop down list populated by an SQL query.My dropdown list gets renders as follows (information slightly altered):
<select name="ddOptions" id="ddOptions">
<option value="--Select--">--Select--</option>
<option value="test">test</option>
[code].....
View 1 Replies
Mar 23, 2008
unordered text file of 3 columns to assign into 2 arrays. I've been given a graphing component which expects a two dimensional array for a scatter graph for the set of values in the last column.
How would I parse through the list given an indexed array of 215 possible 'zone alarm locations' and if an alarm log list item, of which there can more than one for any given zone location, compare in the two dimensional array any previous value and replace it with the higher valued one? The following are my declarations for the 2 arrays. It isn't clear to me why the array for the scatter data was defined as (999,1) knowing there are only 215 possible x values (alarm zone locations)
[Code]...
View 6 Replies
Feb 2, 2009
I have a list box and a text box on a form. What I want to happen is when a user clicks an item in the list box the selected item will be displayed in the text box. I am using object data sources. Here is the code I have so far:
Imports System.Data.SqlClient
Imports CreditCardData
Public Class frmModifyCreditCard
Dim creditCardList As List(Of CreditCard)
[Code]...
View 2 Replies