|
I would have suggested adding the controls to a collection. It seems that adding the Index property to the control is backwards, since it doesn't know it's position in a collection, nor should it care.
|
|
|
|
|
You can loop over the controls collection using the as keyword. so if 'control' is the control value as you loop
Dim lb as Label = control as Label
I think that will work. lb will be null if the control is not a label. I am translating C# in my head here, the syntax may be wrong. But, in this way, you can find all the labels in your form and do the same thing to them.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
What you have is pretty close to what you would want. There is no reason I can think of to try to "remove the originals" as all you would be doing is setting a pointer to null. Assigning the controls to the array does not make a duplicate of the control. As for setting all the properties, you could simply loop through the array after it is created to set the properties and add event handlers. It would then look something like this:
Private lblDestination() As Label
Private Sub frmMain_Load(ByVal sender as Object, ByVal e As EventArgs) Handles MyBase.Load
'I usually create the array in a single line of code. This keeps me
'from having to know the correct number of labels when initializing the array
lblDestinations = New Label() {lblDestinationTemp, lblDestinationBottomTemp}
'set properties and event handlers
For i As Integer = 0 to lblDestinations.Length - 1
lblDestinations(i).Text = "My Label " & i.ToString()
AddHandler lblDestinations(i).Click, AddressOf LabelClick
Next
End Sub
|
|
|
|
|
I think you're right. The origs would not need to be removed because of the pointer since a true copy is not being created and memory isn't really being wasted.
Sigh. Hate when the obvious things skip by sometimes
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I am working to add some additional functionality to a project and without changing anything to a particular form and DataSet object I began getting the error "There is already an open DataReader associated with this Command which must be closed first.". I am using a DataSet object that is actually part of the project which contains 2 datatables. I fill one for a large datagridview and fill the other table based on the row selection in the first. This has been working fine until today. I have already tried the "MultipleActiveResultSets=true;" parameter in the connection string and it makes no difference.
Resolution:
I just began setting the Dataset connection programmatically to override what was set at design time. I was using the same connection for both table adapters and after letting Ben's response sink in I realized what I was doing.
Thanks!
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
modified on Tuesday, November 25, 2008 2:57 PM
|
|
|
|
|
The message means exactly what is says; there is a DataReader created from the command's ExecuteReader() function that has not been closed. You'll have to trace through the code, find it and close it. I think it's common for this kind of thing to be done in a finally block, so maybe you inserted code to re-use a command object inside a try block where a DataReader is created from the command's ExecuteReader() function and has not been closed since the finally block hasn't executed.
Keep It Simple Stupid! (KISS)
|
|
|
|
|
If it was the code I wrote I would have all of that done but all I am doing is calling a TableDataAdapter that is created from the .NET Dataset to fill the local datatable contained in my instance of that dataset.
As I said before, this was not an issue, I did not change anything and am now having to track it down. Here is the code where it breaks.
<br />
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _<br />
Global.System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter"), _<br />
Global.System.ComponentModel.DataObjectMethodAttribute(Global.System.ComponentModel.DataObjectMethodType.Fill, false)> _<br />
Public Overloads Overridable Function GetCustomerDetailsCustomerDetailID(ByVal dataTable As CustomerDetail.CustomerDetailsDataTable, ByVal CustomerDetailID As Global.System.Nullable(Of Integer)) As Integer<br />
Me.Adapter.SelectCommand = Me.CommandCollection(1)<br />
If (CustomerDetailID.HasValue = true) Then<br />
Me.Adapter.SelectCommand.Parameters(1).Value = CType(CustomerDetailID.Value,Integer)<br />
Else<br />
Me.Adapter.SelectCommand.Parameters(1).Value = Global.System.DBNull.Value<br />
End If<br />
If (Me.ClearBeforeFill = true) Then<br />
dataTable.Clear<br />
End If<br />
Dim returnValue As Integer = Me.Adapter.Fill(dataTable)<br />
Return returnValue<br />
End Function
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
how can i delete a question i wrote?
|
|
|
|
|
Last of your post que.
ex:-
Reply,etc... [Edit/Delete]
|
|
|
|
|
i dont have these options
|
|
|
|
|
I think you are not the registered user, register yourself if not.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
There's nothing more annoying that people who delete their questions after they have been answered. What possible reason could you have to do that ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: What possible reason could you have to do that ?
Realization that you have asked question in wrong forum or if you have got flamed or whatever.
Moreover, how does VB comes into picture here?
Loading signature. Please wait...
|
|
|
|
|
Hi,
I have this file
11,misc,0008,AMM /RUH /DMM(RJ),0023,18:00-24:00,0002,RJ ,00704,AMM ,RUH ,060331,2200,000,5,001286,003,175,-01,001,006,N,000,000,000,000,000,000,000,000,000,000,Y,N,000,000,000,000,000,000000000,000000000,000000000,000,000,000.00,000,000.00,000,000
13,J,J ,001,003,175,000,000,000,Y,001,Y,N,000.00,023,000,000,000,000,000,000,000,000,Non,0000.00,0000.00,000,000,000,000,000,000.00,000.00,000,000,001.00,000.00,000.00,000,000,000,000,000,000,000,000,000,000430,N,N,N,N,-01,100,000,000,006,000,100,000,000,000,000000,000,000,000,000,000,000,000,000,000286,000286,000430
14,J,J ,023,000,000,000,000,000,000,000,024,-01,000,000,000,000,000,000
13,J,U ,002,003,175,000,000,000,Y,001,N,Y,000.00,023,000,000,000,000,000,000,000,000,Non,0000.00,0000.00,000,000,000,000,000,000.00,000.00,000,000,001.00,000.00,000.00,000,000,000,000,000,000,000,000,000,000001,N,N,N,N,-01,100,000,000,006,000,100,000,000,000,000000,000,000,000,000,000,000,000,000,000001,000001,000001
14,J,U ,023,000,000,000,000,000,000,000,024,-01,000,000,000,000,000,000
12,J,003,175,000,Y,N,000.00,000,000,000,000,000,000,000,000,000,000,000,000,000.00,000.00,000,000,000.00,000.00,001.00,000,000,000,000,000,000,000,000,000,N,N,N,N,000000000,000000000,000000000,000000000,000000000,000,000,000,000,000
13,Y,Y ,003,003,175,000,000,000,Y,003,Y,N,000.00,023,000,000,000,000,000,000,000,000,Non,0000.00,0000.00,000,000,000,000,000,000.00,000.00,000,000,001.00,000.00,000.00,000,000,000,000,000,000,000,000,000,000375,N,N,N,N,-01,100,000,000,006,000,100,000,000,000,000000,000,000,000,000,000,000,000,000,000275,000275,000375
14,Y,Y ,023,000,000,000,000,000,000,000,024,-01,000,000,000,000,000,000
13,Y,S ,004,003,175,000,000,000,Y,003,N,N,000.00,023,000,000,000,000,000,000,000,000,Non,0000.00,0000.00,000,000,000,000,000,000.00,000.00,000,000,001.00,000.00,000.00,000,000,000,000,000,000,000,000,000,000253,N,N,N,N,-01,100,000,000,006,000,100,000,000,000,000000,000,000,000,000,000,000,000,000,000124,000124,000253
14,Y,S ,023,000,000,000,000,000,000,000,024,-01,000,000,000,000,000,000
13,Y,N ,005,003,175,000,000,000,Y,004,N,N,000.00,023,000,000,000,000,000,000,000,000,Non,0000.00,0000.00,000,000,000,000,000,000.00,000.00,000,000,001.00,000.00,000.00,000,000,000,000,000,000,000,000,000,000243,N,N,N,N,-01,100,000,000,006,000,100,000,000,000,000000,000,000,000,000,000,000,000,000,000207,000207,000243
14,Y,N ,023,000,000,000,000,000,000,000,024,-01,000,000,000,000,000,000
13,Y,M ,006,003,175,000,000,000,Y,005,N,N,000.00,023,000,000,000,000,000,000,000,000,Non,0000.00,0000.00,000,000,000,000,000,000.00,000.00,000,000,001.00,000.00,000.00,000,000,000,000,000,000,000,000,000,000227,N,N,N,N,-01,100,000,000,006,000,100,000,000,000,000000,000,000,000,000,000,000,000,000,000185,000185,000227
14,Y,M ,023,000,000,000,000,000,000,000,024,-01,000,000,000,000,000,000
13,Y,H ,007,003,175,000,000,000,Y,006,N,N,000.00,023,000,000,000,000,000,000,000,000,Non,0000.00,0000.00,000,000,000,000,000,000.00,000.00,000,000,001.00,000.00,000.00,000,000,000,000,000,000,000,000,000,000210,N,N,N,N,-01,100,000,000,006,000,100,000,000,000,000000,000,000,000,000,000,000,000,000,000111,000111,000210
14,Y,H ,023,000,000,000,000,000,000,000,024,-01,000,000,000,000,000,000
13,Y,B ,008,003,175,000,000,000,Y,007,N,N,000.00,023,000,000,000,000,000,000,000,000,Non,0000.00,0000.00,000,000,000,000,000,000.00,000.00,000,000,001.00,000.00,000.00,000,000,000,000,000,000,000,000,000,000190,N,N,N,N,-01,100,000,000,006,000,100,000,000,000,000000,000,000,000,000,000,000,000,000,000166,000166,000190
14,Y,B ,023,000,000,000,000,000,000,000,024,-01,000,000,000,000,000,000
13,Y,G ,011,003,175,000,000,000,Y,010,N,Y,000.00,023,000,000,000,000,000,000,000,000,Non,0000.00,0000.00,000,000,000,000,000,000.00,000.00,000,000,001.00,000.00,000.00,000,000,000,000,000,000,000,000,000,000001,N,N,N,N,-01,100,000,000,006,000,100,000,000,000,000000,000,000,000,000,000,000,000,000,000001,000001,000001
14,Y,G ,023,000,000,000,000,000,000,000,024,-01,000,000,000,000,000,000
13,Y,V ,012,003,175,000,000,000,Y,011,N,N,000.00,023,000,000,000,000,000,000,000,000,Non,0000.00,0000.00,000,000,000,000,000,000.00,000.00,000,000,001.00,000.00,000.00,000,000,000,000,000,000,000,000,000,000170,N,N,N,N,-01,100,000,000,006,000,100,000,000,000,000000,000,000,000,000,000,000,000,000,000106,000106,000170
14,Y,V ,023,000,000,000,000,000,000,000,024,-01,000,000,000,000,000,000
13,Y,X ,013,003,175,000,000,000,Y,012,N,Y,000.00,023,000,000,000,000,000,000,000,000,Non,0000.00,0000.00,000,000,000,000,000,000.00,000.00,000,000,001.00,000.00,000.00,000,000,000,000,000,000,000,000,000,000001,N,N,N,N,-01,100,000,000,006,000,100,000,000,000,000000,000,000,000,000,000,000,000,000,000001,000001,000001
14,Y,X ,023,000,000,000,000,000,000,000,024,-01,000,000,000,000,000,000
14,Y,T ,023,000,000,000,000,000,000,000,024,-01,000,000,000,000,000,000
12,Y,003,175,000,Y,N,000.00,000,000,000,000,000,000,000,000,000,000,000,000,000.00,000.00,000,000,000.00,000.00,0
i need to read the lines that start with 11 first, then the ones that starts with 12, then 13 and ignore 14...
i started with this code:
'Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\hi.txt")
' MyReader.TextFieldType = FileIO.FieldType.Delimited
' MyReader.CommentTokens = New String() {"14"}
' MyReader.SetDelimiters(",")
' Dim currentRow As String()
' Dim test As String = ""
' While Not MyReader.EndOfData
' currentRow = MyReader.ReadFields()
' Dim currentField As String
' For Each currentField In currentRow
'
' test &= currentField & " "
' TextBox2.Text = test
'
' End If
' Next
' End While
'End Using
can anyone help me?
|
|
|
|
|
Hi,
You can read this file in to one temperary dataset and datatable.
By checking the values in the cells you can read whichever row you want.
This is one easiest way, may be if you can find any more effective ways to
do it for improving performance do little much research.
But the easiest way is which I have shown you.
Thanks a Lot,
Aleem Mohammad.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
i wanna read them so i can insert them in a database starting with lines 11, then insert 12 , then 13
|
|
|
|
|
Unless you need data from lines starting 11 to use in lines starting 12 etc then there is no need to read them in a specific order - when you retrieve the data from the database do an order by. That is one of the advantages of a database.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Actually i need data from 11 to use in 12, the whole idea is to read line 11 insert it into database, then insert the 12 related to that 11 into database, then the 13 that are related to them
|
|
|
|
|
In which case why not read the entire file and store the different record types in (say) dictionaries so you can jus use them as required.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Why not read them all with file.readalllines, then build a map of lists of strings and thus sort them according to the sets you're after, and then work through those lists ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
You could try something like this.
The example data could be interpreted as
(a) a set of files where each file contains one 11 record,
or (b) one file that has multiple 11 records with each one followed by 12, 13 and 14 records.
I assume the latter.
Imports System
Imports System.Text
Imports System.IO
module CSVReader
public Sub Main()
Dim theFile As String = "C:\PlayPen\TheData.txt"
Dim rdr As StreamReader = new StreamReader(theFile)
Using (rdr)
Dim theKey As String = ""
Dim input As String
Dim recType As String
while (rdr.Peek >= 0)
input = rdr.ReadLine() 'Should check that not a blank line
Dim recArray As String() 'if there is one then following fails
recArray = input.Split(",")
recType = recArray(0)
Select Case(recType)
case "11":
theKey = recArray(1) 'Need to change this to get type 11 key
Process11(input)
case "12":
Process12(theKey, input)
case "13":
Process13(theKey, input)
case "14":
Process14(theKey, input)
case else
Console.WriteLine("Oops: {0}", input)
End Select
End While
End Using
End Sub
private Sub Process11(rec As String)
Console.WriteLine("Proc11 {0}",rec)
End Sub
private Sub Process12(key11 As String, rec As String)
Console.WriteLine("Proc12 key = {0}: {1}", key11, rec)
End Sub
private Sub Process13(key11 As String, rec As String)
Console.WriteLine("Proc13 key = {0}: {1}", key11, rec)
End Sub
private Sub Process14(key11 As String, rec As String)
Console.WriteLine("Proc14 key = {0}: {1}", key11, rec)
End Sub
End Module
The text file I used to test this is as follows:
11,one,xyz
13,abc_one,xyz
12,aaa_one,xyz
14,bad_one,xyz
13,abc_one,xyz
12,aaa_one,xyz
11,two,xyz
13,abc_two,xyz
14,bad_two,xyz
13,abc_two,xyz
14,bad_two,xyz
14,bad_two,xyz
13,abc_two,xyz
13,abc_two,xyz
14,bad_two,xyz
11,three,xyz
12,aaa_three,xyz
13,abc_three,xyz
11,four,xyz
14,bad_four,xyz
12,aaa_four,xyz
13,abc_four,xyz
11,five,xyz
12,aaa_five,xyz
12,aaa_five,xyz
14,bad_five,xyz
14,bad_five,xyz
14,bad_five,xyz
14,bad_five,xyz
13,abc_five,xyz
13,abc_five,xyz
11,six,xyz
12,aaa_six,xyz
Obviously your data has more fields but the general technique should work.
|
|
|
|
|
|
Hmmm!
Not sure from your reply whether this was helpful or not.
From your original post it looked like you needed to process a text file with type 11 records followed by other types in no particular order. I just used some standard 'Control-Break' type processing that is well known to COBOL programmers (though some of them would not like the Select Case - particularly those brought up on Jackson Structured Programming!)
|
|
|
|
|
Hi,
I want to understand the compilation and runnung techniques of VB. I am .Net programmer, have been assigned with some small VB task.
I am frequently strucking up because of lack of understanding VB and its compilation and running techniques(IDE).
For example, there is one project which I have added in to my application and want to use it.
When I compile it, it is compiling but when I run it it is saying compilation error "User-defined type not defined".
When I added a library and tried for running the application then I got the following message "No creatable public component detected"
I am unable to follow this, so please anybody can provide me some hints or links to better understand the VB 6.0 IDE, so that atleast I can run any given code.
Because I am not strucking up at code, I am understanding the code very well but strucking up at the small techniques.
Please can any body help me in overcoming this. I would be very much thankfull.
Thanks a Lot,
Aleem Mohammad.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
modified on Tuesday, November 25, 2008 2:30 AM
|
|
|
|
|
Oh, you're stuck in VB6 hell. That really sucks. VB6 has been dead for some time.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|