.net - Execute A Command On A Collection Of Items, Functionally
Jul 12, 2011
I've done a little bit of LINQ but I almost exclusively return some elements from a collection based on some criteria. Now I'm trying to do something similar; let's say I have 50 winForm Controls in a collection - I want to set the .Visible property = True based on the controls name.
How would I do that? Below is my failed attempt.
myControls.AsEnumerable.Select( Function (myControl as Control) ( myControl.Visible = (myControl.Name <> "Hidden")) )
It compiles and even executes but does nothing.
View 1 Replies
ADVERTISEMENT
Sep 7, 2011
I have the following classes:
Product, Service and OrderItem
Product and Service must inherit OrderItem. So basically I want to store OrderItem object in my shopping cart and these object are store in a list.
Public MustInherit Class OrderItem
Private m_enuItemType As TypeOfItem = TypeOfItem.None
Private m_strUserID As Integer[code].....
View 1 Replies
Jan 16, 2010
I want to add a new select command to my dataset. To do that, I have added a new partial class to my project. Because we have to use partial class if we want to extend generated dataset codes. [code]...
View 3 Replies
Apr 6, 2012
currently in my application I have a Global Collection that is a Collection of Collections.Currently I am trying to add items/ elements to one of the child collections of the Global Collection but I am unable to use the collections methods of the child.When I assign a variable to the child collection and return the collection it is just an object with the collection inside.
Ex:
Dim GlobalCollection as New Collection
Dim ChildCollection1 as New Collection
Dim tempCurrentCollection[code]......
View 3 Replies
Aug 4, 2011
We have some third party code that is causing some misery at the moment due to throwing the above error: it is slightly odd because it is an intermittent error. Here is the method that is causing the issue:
Private Shared Sub IntLocateDictionaries(ByVal haystack As ExpDictionary,
ByVal needlearray() As Object, _
ByVal resultarray() As Object, ByVal removemarks As Boolean)
Dim i As Integer
Dim item As Object
[Code] .....
I understand that this error is usually caused by trying to modify a collection whilst enumerating around it, hence why I've added logging on the only line that looks like might alter the collection... Since adding the logging we have still experienced the issue but NO LOGGING appears: this isn't surprising since if you look at the parameters on the calling line (the only place this Sub is called from) - removemarks is passed as False - this will be passed all the way down through the recursive calls and so that line which calls .Remove never gets executed....the fact we don't see logging proves this....
View 2 Replies
Feb 17, 2012
I am working on a project where I have a personnel class. The records stored in the class are populated a few records per second. At the time I am inserting the records, I have to check the same class to ensure the same record is not added twice. Since I am looping through the class using "For Each", I get a message "Collection was modified; enumeration operation may not execute".
View 5 Replies
Mar 11, 2009
i'm getting the following error: "COLLECTION WAS MODIFIED; ENUMERATION OPERATION MAY NOT EXECUTE."
The stack trace is ;
at System.Collections.SortedList.SortedListEnumerator.MoveNext()
at SatcomDiscoverySocket.clsGatewaySend.SendViaGatewaySend() in C:Documents and Settingsjim.SATCOM_DOMAINMy DocumentsVisual Studio 2005ProjectsSatcom Discovery Socket ServerSatcomDiscoverySocketSatcomDiscoverySocketThread PollingclsGatewaySend.vb:line 60
The line in question is but I don't believe that to be true I think its the line above it;GatewaySendEntry = Nothing The code is below. I can't figure out why, it's causing the error at that line and how to fix it.
[Code]...
View 17 Replies
Oct 15, 2009
I have this flood-fill algorithm, based on a queue (I tried the recursive method but pictures are too big and it was causing stack overflow).The problem is that when it makes the second pass in the for-each loop, the program crashes and compiler gives me the message "Collection was modified; enumeration operation may not execute.".Well, of course I know the collection was modified (it supposed to be!) since I am adding necessary items to it on-the-fly within the loop. What I cannot understand is why it happens since the for-each is based on the remaining items in the collection and not in a numeric index.
Below, the actual code:
Code:
Public Sub FloodFill(ByVal myx As Integer, ByVal myy As Integer)
Dim icoord As coordinate
Dim ocoord As coordinate
[code]....
View 2 Replies
Mar 29, 2010
I'm wondering, in Visual Basic 2008, how to execute an external dos command and get its output without help of an intermediate file (to speed up)?
View 1 Replies
Jul 1, 2010
Its something in the syntax for the command.
They provide this example in VB:
Dim MtbApp As New mtb.Application
Dim MtbProj As mtb.Project
Dim MtbCom As mtb.Command
[Code]....
what I'm expecting should happen is Minitab should open, and the command should execute. However, whats happening is that two instances of Minitab are being opened and neither are showing user interface, I have to find them in processes.
View 1 Replies
Feb 25, 2010
Using VB.Net and C#.Net
Using 3 Tier, I was executing this query in DataAccessLayer, i want to call this query in ApplicationLayer throgh BUsinessLogicLayer.
Code.
Cmd = New SqlCommand("Exec delTable", con)
cmd.ExecuteNonQuery
I want to return this execute command like this,
In application Layer How to call this?
View 2 Replies
Jul 18, 2009
Lets say i have a text box and i type picturebox.visible = false; then i press a button to execute it. and My Picturebox is not visible now.so How do i run that command since it was in a text box???
View 7 Replies
May 14, 2012
Is there a way to execute SQL command for a Dataadapter rather than regular approach.
I i have parameters to pass to the SQLCommand. In he below model DAtaadapter at declaration itself we need to pass the SQL as string, and Conn. But i wan to send SQL Command to the adapter to execute instead command as string
Previously i have used to fill dataadapter as below
dbSource = "Database= DataBase;"
conn.ConnectionString = dbProvider & dbPassword & dbSource
If conn.State = ConnectionState.Open Then
[Code]....
View 2 Replies
Aug 2, 2011
I am making a console application that will be prompted from a cmd. I want to be able inside my application to start an other program. Here is the line I am trying to use: %SystemRoot%Microsoft.NETFrameworkv4.0.30319MSbuild.exe /p:Configuration=Release test.shfproj This is making Sandcastle Help File Builder create a documentation with the test.shfproj i've builded previewsly.
[Code]...
View 2 Replies
Feb 26, 2009
I am a C++ developer and completely new to Visual Basic so please excuse me if you find the question too dumb wrt a VB developer.I am porting a VB script to VB.Net. The VB script is using the following command :xecute(<variable containing more VB code>)Now, this command doesn't work in VB.Net and I am not able to find its equivalent in VB.Net ??
View 4 Replies
Mar 11, 2011
I am a C++ developer and completely new to Visual Basic so please excuse me if you find the question too dumb wrt a VB developer.I am porting a VB script to VB.Net. The VB script is using the following command : Execute(<variable containing more VB code
View 13 Replies
Dec 29, 2011
This is what happened: on the form load of my application i created a background worker to bind collection (records from database filled in the dataset) on my control. but the problem is when the i updated the records on the database it throws an error if i run this procedure again.
If xControl.InvokeRequired Then
Dim MyDelegate As New InitializeDataBinding_Delegate(AddressOf InitializeDataBinding)
Invoke(MyDelegate, New Object() {xControl, xQuery, xPrimaryKey}) ' ERROR HERE SAYING: Collection was modified; enumeration operation may not execute.
[Code]...
View 2 Replies
Oct 27, 2011
I'm getting a Collection was modified; enumeration operation may not execute error every time I try to close this form. I suspect it has something to do with the StringBuilder() which I have declared in the starting form (Details1). I have already spent hours looking for the problem. It does not throw an error when I debug, only when I install on other machines.
[Code]...
View 1 Replies
Oct 15, 2011
I am encountering an error when looping through datarows. I searched SO and tried the solutions, but no luck. Collection was modified; enumeration operation might not execute.
Dim dRow As DataRow
For Each dRow In dt.Rows
dt.Rows.Add(dRow("CustNum"), dRow("SalesRepName"), dRow("mgrid"), "=""" & dRow("midValue") & """", dRow("dba"), dRow("sysDate"), dRow("statusID"))
Next
The error occurs the first time the code hits "Next". What would be causing Collection was modified; enumeration operation might not execute.How can I resolve this error?
View 2 Replies
Nov 28, 2010
I have a multithreaded app that is throwing the following error.Collection was modified; enumeration operation might not execute.[code]I'm pretty sure the collection is being modified by another thread. I attempted to fix the problem with the SyncLock's but clearly I'm missing something here.I thought I could lock the object by properly using SyncLocks, am I just not locking the right object(s)? Or am I completely missing something here.Besides using SyncLocks what other options do I have to prevent this error. I was thinking perhaps a global variable to keep track critical code sections so that no 2 threads enter.I'm also a little confused about what collection is being modified my first guess was CLResultsDataTable. ResultsDataTable, but I'm not sure.This is an older project I just recently picked back up so I'm still stepping through a lot of code to try to figure out how/why this is happening
View 3 Replies
Jan 10, 2011
I'd like some help with this error that other users has when they launch the app I created. I will copy / paste the error
Tittle: Collection was modified; enumeration operation may not execute.
Error:
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
[code].....
View 10 Replies
Dec 16, 2009
I have an executable that I normally execute from cmd window. Now I want to write a vb program that does it, captures the output that the program would normally show on commandwindow and does some further stuff with it. Shell would be the starting point, I guess.
[Code]...
View 2 Replies
Mar 2, 2011
I am working on a vb.net project and i have a "start" and "Pause" Buttons on the FormPost.exe
I am trying to schedule a batch process to run every day in the morning at 4:00 AM.
How can i run a command prompt to execuite FormPost.exe and them click on "start" button, all via command prompt?
View 2 Replies
Sep 20, 2009
I know of the Shell method to run files, but how can I execute normal command prompt commands like nslookup, and capture the output as a string?
View 1 Replies
Apr 21, 2011
I am trying to execute a shell command with vb.net that includes variable from the vb.net code.I have experience with batch, and Unix scripting. I had to modify the contents of the code as it is confidential to me at the moment.Example of my problem:
Dim Variable1 As String = "Location_to_.exe"
Dim Location As String = "UNC_Path_Goes_Here"
Dim Options As String = "/Options go here"
Shell("cmd.exe", /C Variable1, Location, Options) This is something that must be run from CMD.exe and I am trying to do it this way to make it as dynamic as possible.
View 3 Replies
May 23, 2011
Lets just say we have this as Command1 Dim Command1 = "whoami.exe >> C:Hello.Txt" The program will read a list of users from a text file and then perform the action on each of them. If the user does not exist, or they are part of a password protected computer, I would like to see that in my printout. I have this but am Unsure how to write the If Then Statement (If that is the ebst route to take)
[Code]...
View 2 Replies
Feb 19, 2010
I'm trying to send an HTTP command using VB.NET and I'm not quite sure how to do it. I don't want to actually navigate to the page, just execute the command.[URL]..
What I'm doing is building an integrated interface for my XBMC home theater, and my home automation.
View 2 Replies
Jun 16, 2009
I need to convert a .tex file to a .dvi file (latex file), which I can do simply using a command in the cmd window: "latex C: est.tex" for example, would create the "test.dvi" file from the "test.tex" file.
I know how to start the cmd window (Process.Start("cmd.exe")), yet how to get VB to actually 'type' a message and execute it...
View 11 Replies
Aug 6, 2009
Is there a way to "execute" a string variable as a command? [code]
View 9 Replies
Sep 27, 2011
I am using ASP.NET
If I want to execute my Insert command from my SqlDataSource in my code behind I would do this.
SqlDataSource1.Insert()
But how would I be able to do this in JavaScript?
<script type='text/javascript' language="javascript">
function valSubmit() {
//Need to call the Insert Command here!
[Code].....
Where in my code behind can I place the Insert() command to make sure only after my valSubmit() function in JavaScript have executed it will then execute the Insert Command?
View 2 Replies