VS 2008 Enumerating A List Generically?

Jan 7, 2010

Is there a way to write a single routine that could enumerate a list regardless of the data type? I am trying to write a custom XML serialization class and it would be great if I could enumerate all items in a generic list the same way, regardless if it was of type String, Integer, etc.

View 5 Replies


ADVERTISEMENT

Get A List (or More Generically, Just An Object) Available Multiple Places?

Aug 23, 2011

In a program that I'm responsible for, we want to start keeping track of milestones. These milestones are quite simple and consist of a unique identifier, the project they're assigned to, a description, and a date that they should be accomplished by (or not, if there's no concrete due date).We use a slightly modified Model-View-Presenter architecture, and currently I'm passing this list around through the presenters, but it seems fairly clunky, so I was wondering:What's the best way to make this list available to all the presenters/views that need it?We're using VB.NET 3.5, and I was toying with the idea of making this a shared property of the main presenter, but it does seem like that adds some unnecessary coupling.

View 1 Replies

Enumerating List Of Drives On A Remote Domain Workstation

Jun 29, 2011

I am trying to come up with a good way to enumerate hard disks on remote workstations, possibly including administrative shares, so I can audit key files on them without having to access them via sneakernet.I have domain administrator rights. Security policy prohibits using WMI which would be a great solution.I can retrieve a list of computers using Active Directory, but I need some way to determine what drives are available on each system. Is such a thing feasible? A fellow developer offered some VB6 code from years ago that used WNetOpenEnum, but I was hoping that since we are at .NET framework 4, maybe there's a more elegant / managed way of working with this. I'm keen to use technologies that are more generally supported, such as standard APIs etc. WMI is a great solution but apparently is blocked by default by Windows Firewall, so its availability is not guaranteed.

View 2 Replies

.net - Using Reflection For Generically Typed Delegate And Interfaces?

Aug 24, 2009

I have a bunch of classes that each have a property called Sequence. This property is implemented from an interface called ISequenced. For this example lets call one of these classes A. When I have a List(of A), I want to be able to sort them using the standard List.Sort(addressof delegate) where the delegate is a standard function that takes in two ISequenced objects and compares their sequence numbers and returns a boolean flag, rather than declaring a function for each individual class that implements ISequenced.

E.g.

Dim li as List(of A) = GetValues()
li.Sort(addressof SortBySeq)
...
Public Function SortBySeq(ByVal ob1 as ISequenced, ByVal ob2 as ISequenced) as

[Code]...

How would I declare the function in order to do this (if it is even possible in VB.NET?

View 2 Replies

Generically Implement Exception Logging If I Have Already Got Many Try-catch Block?

Apr 20, 2012

I am writing ASP.Net Web-form in VB.

I have a system which have already handled exceptions by try-catch blocks everywhere.How do I quickly and generically implement exception logging like overriding something instead of inserting logging functions in every single catch block?

View 1 Replies

Enumerating Controls With Variables?

Jun 22, 2010

If I had 5 text boxes on a form, TextBox1...TextBox5, is there a method to do something like this?

Dim strFld As String
For intFor = 1 to 5
strFld = "TextBox" & intFor
Me(strFld).Text = intFor
Next

It doesn't like the line of Me(strFld) but I figure there must be a way to reference a field via a variable instead of hardcoding the field name.

View 6 Replies

Enumerating Strings As Bytes?

Apr 24, 2012

I was looking for a way to enumerate String types in (vb).NET, but .NET enums only accept numeric type values.

The first alternative I came across was to create a dictionary of my enum values and the string I want to return. This worked, but was hard to maintain because if you changed the enum you would have to remember to also change the dictionary.

The second alternative was to set field attributes on each enum member, and retrieve it using reflection. Surely enough this worked aswell and also solved the maintenance problem, but it uses reflection and I've always read that using reflection should be a last resort thing.

So I started thinking and I came up with this: every ASCII character can be represented as a hexadecimal value, and you can assign hexadecimal values to enum members. You could get rid of the attributes, assign the hexadecimal values to the enum members. Then, when you need the text value, convert the value to a byte array and use System.Text.Encodings.ASCII.GetString(enumMemberBytes) to get the string value.

Now speaking out of experience, anything I come up with is usually either flawed or just plain wrong. Is there any reason not to do it like that?

As pointed out by David W, enum member values are limited in length, depending on the underlying type (integer by default). So yes, I believe my method works but you are limited to characters in the ASCII table, with a maximum length of 4 or 8 characters using integers or longs respectively.

View 1 Replies

LINQ To XML Enumerating Over Descendants

Jan 13, 2011

I am trying to write a simple linq query from a tutorial I read. But i cannot seem to get it to work. I am trying to display both the address in the attached xml document, but can only display the first one.

<?xml version="1.0" encoding="utf-8" ?>
<Emails>
<Email group="FooBar">
<Subject>Test subject</Subject>
<Content>Test Content</Content>
[Code] .....

View 1 Replies

DB/Reporting :: Enumerating AD Properties From A DirectorySearcher

Apr 17, 2008

I am trying to get the AD Properties from a Search that I do. When I do so I get this as a result "System.DirectoryServices.ResultPropertyValueCollection". How do I get the value? I know that it is a collection but everytime I try I am not successful.

Code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
Dim resEntry As SearchResult
Dim lstItem As New ListViewItem
Dim currentEntry As New DirectoryEntry

[CODE]...

View 4 Replies

Enumerating Only 'active' Domain Machines?

Apr 3, 2009

I'm having trouble with program I'm writing for work. It's basically a GUI for some remote management scripts I wrote a while back.I have a listbox (listbox1) to which loads a list of computers from active directory, which works perfectly and quickly.The problem is that I also want to add to another listbox (listbox2) a list of machines 'currently active' on the network. I can't see an easy way to do this in .net but came up with a logical solution.Basically my thought was to 'ping' all of the machines in the directory listing and use the results to make the list...

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim de As New DirectoryEntry()

[code].....

View 3 Replies

.NET - Enumerating The Handles Not Windows Of A Specific Process?

Oct 16, 2009

I have some code designed to locate a specific process based off of its window text, gather the main handle, and then all of the child windows. However, I have run into one problem. I cannot seem to gather all the handles and their respective text. For example, when I test my program and do a handle count on the specific process, it tells me that there are more than 400 handles for this one process. How do I get the handle pointers for this process and also gather the text associated with these handles.I have included my source code for reference.

Code:Public Class Form1
Const GW_CHILD As Integer = 5 Const GW_HWNDNEXT As Integer = 2 Const WM_GETTEXT As Integer = &HD Const WM_GETTEXTLENGTH As Integer = &HE Const BM_SETSTATE As Integer = &HF3 Const WM_LBUTTONUP As Integer = &H202 Const WM_LBUTTONDOWN As Integer = &H201

[code]....

View 1 Replies

Enumerating The Handles Not Windows Of A Specific Process?

Aug 30, 2010

I have some code designed to locate a specific process based off of its window text, gather the main handle, and then all of the child windows. However, I have run into one problem. I cannot seem to gather all the handles and their respective text.

For example, when I test my program and do a handle count on the specific process, it tells me that there are more than 400 handles for this one process. How do I get the handle pointers for this process and also gather the text associated with these handles.

I have included my source code for reference.

Code:Public Class Form1
Const GW_CHILD As Integer = 5 Const GW_HWNDNEXT As Integer = 2 Const WM_GETTEXT As Integer = &HD Const WM_GETTEXTLENGTH As Integer = &HE Const BM_SETSTATE As Integer = &HF3 Const WM_LBUTTONUP As Integer = &H202 Const WM_LBUTTONDOWN As Integer = &H201

[code]....

View 9 Replies

Internet Explorer 8 :: Enumerating Tabs In IE8 And Firefox?

Jun 27, 2011

Is there a way to list the text that appears in each of the tabs of IE8 and Firefox as part of the list of running processes along with the handle.I can list all the running processes fine with their hwnd's but I cant list all of the tabs that are open in either IE8 or Firefox, only the active tab

View 1 Replies

VS 2005 Enumerating Items In Outlook Mailbox?

Oct 26, 2009

I need to enumerate all the items in an email inbox. However, this code fails

For Each MI As Outlook.MailItem In folderToProcess.Items
'Console.WriteLine("Subject:" + vbTab + MI.Subject)
Console.WriteLine(MI.Subject)
Next

It fails whenever it comes across an item that ISN'T an email (e.g. a meeting request). I've spent the last hour or so trying to find a way of enumerating every item no matter its type. So far all I've come up with is to use the base Object type and then work from there but that's Late Binding and I'd prefer to avoid it if possible.

Has anyone come across this problem before? How can I determine what type of Outlook item it is during enumeration?

View 3 Replies

Enumerating Host Addresses From IP Address And Subnet Mask

Sep 24, 2011

As part of my application I am hoping to be able to get the user to enter their IP address and subnet mask which will then enumerate all of the hosts in between which can then be scanned for various open ports/applications installed.

For instance, With a network of 10.91.100.0/255.255.255.252 hosts are valid 10.91.100.1 - .2

How can this be done in vb.net? I would assume also some error checking would need to be put in place to confirm as to whether the subnet mask was valid as well?

View 1 Replies

Enumerating Managed Threads Or Determining When A Thread Is Created?

Feb 15, 2010

I have need of either enumerating all the managed threads in a application or listen to when a new thread is created. I can not find anyway to do this through searching the web. It strikes me as odd the the IDE can list all the manage threads, but I can't.

If this is not possible, is there clarification as to why this is not possible.

I need to create a shared class in a DLL that will when it receives a signal will stop all the threads currently running, and gracefully exit the application.

View 3 Replies

Enumerating Outlook Items Crashes When An Undeliverable Email Item Is Found?

Sep 13, 2009

Here's my code:

Code: Public Sub ProcessInbox()
Dim oOutlook As New Microsoft.Office.Interop.Outlook.Application Dim oNs As Microsoft.Office.Interop.Outlook.NameSpace Dim oFldr As Microsoft.Office.Interop.Outlook.MAPIFolder Dim oAttachments As Microsoft.Office.Interop.Outlook.Attachments Dim oAttachment As Microsoft.Office.Interop.Outlook.Attachment Dim

[code]....

If I change the following line as shown, it works OK:

Code: Dim oMessage As Object

Is this the best way to get it to work or what should I specifically define the variable oMessage as?

|+--JDMils|+--VB6 & XL VBA+--VB Dot Net 2K8|

View 3 Replies

VS 2008 Student List Views - List Boxes And Data Fro Access DB Tables

Dec 30, 2010

This is what I'm sure will be the first of many noob-ish questions from yours truly... I'm studying as a mature student for a Computing Degree (encompassing web design, hardware, programming and systems analysis). The programming seems to be my weak spot this year. I enjoyed C++ last year, doing basic console applications, but progamming visually with VB in Visual Studio 2008 I'm struggling!

[Code].....

View 12 Replies

VS 2008 Will Not Need To Update Each Component Variable Of Products List When Components List Changes

Sep 21, 2010

I think (?) this is about object design, and perhaps about structural and/or creational patterns. But a bit hard to say when I only know a couple of patterns yet.[code]But... what if we INSTEAD want each Product instance only to (in some way) refer to one instance of a specific list of Components. So we wan't to save the products list to one file, and the components list to another file. Then would I build the objects the same way, or different? So let's then say we have now Class B as below. [code]

1. Will not need to update each component variable of the products list when the components list changes.

2. If the Product object shall be shown in a DataGridView, for editing properties, it seems easier to implement the selection of the component property.

Is this wrong approach? Is it suitable in some cases, and if so, when? Are there other solutions I perhaps am not aware of that would be appropriate? Is this about structural design patterns? and if so, can the alternatives above be catagorized to some pattern type? I don't really know exactly what I'm looking for.. But I think probably I'm looking to understand whether the object design will be determined by the way the objects are saved.. And if i shall save the objects by serializing to file, vs saving to a database, would I create the business objects differently?

View 4 Replies

VS 2008 - Fetch List Of Directoies From 1 Special Ftp Server Wich Does Not Support LIST Command

Jan 27, 2011

I have a small problem i'm trying to fetch list of directoies from 1 special ftp server wich does not support LIST command i was try this code and it works for all ftp server i have try exept this special one :

'' Get the object used to communicate with the server.
'Dim request As FtpWebRequest = DirectCast(WebRequest.Create("ftp://" & txtFTPhost.Text), FtpWebRequest)

[code]...

I'm getting error 502 which means command is not supported and app crashed. I would just simple said leave it but i have try normal ftp clients like FlashFXp and it works just fine (i can see error in the log but it just pass it and show direcoties)

View 4 Replies

VS 2008 Declare A List(of T) (or List(of <anonymous Type>))?

Jan 7, 2010

Ok i'm trying to declare a global list of type T (or is it <anonymous type>) i declare it in a module with something like Friend query As New List(of {whatever type i try}) the app takes some xml and parses it into a list but i need this list available to other classes and methods within the app, everything i have tried fails resulting in an error like Value of type 'System.Collections.Generic.List(Of <anonymous type>)' cannot be converted to 'System.Collections.Generic.List(Of {whatever type i try})'.

What would be the correct way to declare a list of this type? is there another way i could do this?

View 8 Replies

VS 2008 Search Item A (from A List Of X Items) In List B?

May 5, 2010

i want to search item A (from a list of X items) in list B but i want to get the item not found example Search ITEM A in LIST B if not found then return a print....if found continue with ITEM B..and so on.

View 5 Replies

VS 2008 Displaying A List Within A List In A DataRepeater?

Feb 2, 2010

Firstly i apologise for another topic on a subject i have created already but this is a slightly different question and not related to LINQ at all despite the fact the code uses LINQ (the linq works fine and creates a List(Of Test) where each 'Test' contains a List(Of TestList) This data could be anything i guess and could come from an array or a database rather than xml literals.Ok, essentially i have a list which contains a list and i wish to display all the properties (List and list within this List) onto a DataRepeater Control. I have developed a testbed to get this working so i can implement it into my main application. Firstly I'll show the current code and how to construct the form and after that i will explain what i have tried and what i have had happen from these trials over the last week.

Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

[code].....

View 1 Replies

VS 2008 List Box : List Only The Image It Self?

Jan 19, 2010

i got my list box working.but it lists the path and the name..ist it possible list only the image it self?

Imports System.IO
Public Class Form3
Private Sub FindFiles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindFiles.Click

[code]....

View 12 Replies

Getting A String From A List Box On One Form To A List Box On Another Form In VB 2008

Oct 17, 2010

I need to get a string from an items collection in a list box on one form to a list box on another form in VB 2008. Here is the code (I've tried a couple ways in the code to get the values over).

Public Class frmPrintBooks
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnClose.Click

[Code]....

View 3 Replies

VS 2008 Add A Control To List (Of Control) What Gets Added To List?

Jul 26, 2011

when I add a Control to the List(Of Control) what gets added to the List? Is it the Control or reference to the Control.I have a collection of controls (picture boxes representing notes,comments, icons, etc.), which can be drag and drop into other picture boxes holding read only images. Those controls are never permamently added to those images, they can be move or dispose as needed. I need to save those controls to a file and retrieve it later, however when retrieved, they must be place onto the same location in the image. Saving just the image is not the option, I also need to save all the control attributes.

View 2 Replies

VS 2008 : List FTP Dir In VB?

Jun 11, 2009

This should hopefully be a simple one. I want to list the files and file sizes of a directory on an ftp. I have absolutely no clue how to get into an ftp with VB.I made a batch script that does this but batch can't do the math to convert the file size from bytes to either kb, mb, or gb.

So all I need is to learn is how to get the file names and sizes (other things such as date, owner, permission would be nice to know also) then I can get it to write a file in the format I want. I figure I'll use arguments to choose the directory or if no argument is used root will be listed.

View 5 Replies

Making A To Do List In Vb 2008

Feb 9, 2011

I want to create an app that is constantly running and as part of my desktop toolbar. When I mouse over the icon, I want the list to show in front of all other windows on the screan. I, also, want it to fade away once the mouse leaves the icon.If the icon is clicked, the window displays.

I want to be able to click-and-hold the title bar to move it around when the window is displayed. I want the full display of the window to be a check box list with each line being ~25 characters long. At the top of the window, there should always be an open line on top of the list where I can enter a new "task," and hitting the "ENTER" key will save the line and move it down one line, as well as the entire list underneath

The action of ENTERing a new "task" should spawn a new open line at the top of the checkbox where the user can enter a new task. When a box (located to the left in front of each line of text) is checked for a line, that line will disappear."Checking" a box should move every line underneath of the Checked (and thus deleted) line up one line. There should be a "close" or "minimize" (depending on how you keep in to the task bar) button the hide the app when I'm through using it.

View 1 Replies

Vb 2008 List Box Limit?

Apr 29, 2011

i have 3 list boxes, 2 for selection one displays selection. i want a limit on input in lstbox3. i cant figure the right syntax etc. if lstbox3.count > 2 then is not accepted.

View 2 Replies

VS 2008 - List Of Class(Of T) ?

Aug 15, 2011

If i have the following class:

Is there anyway to load classes derived of this class into a single list kind of like: list(of Test) so that i can itterate through all items and call the load sub in each?

I.E.:

CODE:

View 3 Replies







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