|
Hi there Dave thank you so much for your reply.
(when i say nearly there ive only one more step to go on paper anyway !!!)
Sorry if my description was garbled
Yes i want to read the passwords from a text file.
But i want to add them INTO Col A (APPEND T0)
(Col A already contains info [First 3 chars of forename in LC] )
Column A will then be read by an app my developers are creating which will reset the users password to that in Col A.
Dave,
Im really feeling my way in the dark and have just been playing until i get somthing that works as im really new to scripting anything of consiquence.
Its the appending part that i suppose im really stuck on.
Many kind Regards
Paul
|
|
|
|
|
OK. Same thing, only instead of assigning the string read from the password file to column B, you're combining strings in column A.
Cell(row,col).Value = Call(row,col).Value & TextLineFromFile
|
|
|
|
|
Hi Dave,
Thanks for that.
Ive managed to cobble together some code which will copy from a .TXT to Col A of a .CSV.
Whereabouts\how would i addin your suggestion of:
Cell(row,col).Value = Call(row,col).Value & TextLineFromFile
Where you say (row,col)does that mean i need to specify the row and column..as ive a lot of row data to add.
Code below
-----------------------------------------------------------------------------
Const ForReading = 1
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.Workbooks.Add
i = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\passwords.txt", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrLine = Split(strLine, ",")
oExcel.Cells(i, 1).Value = arrLine(0)
i = i + 1
Loop
oExcel.ActiveWorkbook.SaveAs ("c:\newtest.csv")
objFile.Close
oExcel.Quit
-----------------------------------------------------------------------------
|
|
|
|
|
Sorry
Forgot to add that quite obviously Creates a new file not adding to an existing one....
Paul
|
|
|
|
|
I don't do Office interop so I can't give you the exact syntax, but this is the right idea. You just need to get the existing value of the cell then append the string you read from the file to it and assign the new value to the cell.
|
|
|
|
|
I have an Access DB with a list of members and attendance dates. I have brought the data in with a left join (I need all members regardless of attendance). I need help setting up the following - I would like to be able to choose a member name from a combobox drop down and upon selection populate a datagrid with their attendance information. I need to do two things: Retrieve only unique names from the table for the combobox (right now, every name can have multiple entries because of the attendance join) using some kind of filter, and at the same time when a record with attendance entries is selected remove the filter to populate the datagrid. Right now I am binding the comboxbox to a BindingSource. Could someone walk me through how I would go about this?
Thanks.
|
|
|
|
|
You should ask these questions in the database forum as your problems are SQL-related rather than VB.
Paul Marfleet
|
|
|
|
|
What do you mean? The import and all that is working fine, I just need to know how to filter the datatable for the combobox and at the same moment have it display unfiltered info for the datagrid. In other words, at this point the datatable would look something like this:
MemberID, MemberName AttendID AttendHistory
100,a,1, 12/1/2007
100,a,2, 6/1/2007
100,a,3, 7/1/2007
101,b,1,12/1/2007
101,b,2,1/1/2007
etc.
I need the combo box to only retrieve the unique MemberIDs for its datasource (which I think will require filtering) and once selected to retrieve all of the rows connected to that member (which I think will require removing the filter.
|
|
|
|
|
have the datagrid continue to be connected to the datatable.
for your combobox have it be connected to a dataview. first setup the dataview filtering out the records you want. just check the help or internet on how to use a dataview.
|
|
|
|
|
Thanks.. so you are saying that so long as the source of data (ie the datatable) is showing all of the information, when I move through the records, the filtered dataview and unfiltered datatable will be in sync?
|
|
|
|
|
Yeah, the import is working fine, but your database stucture is total garbage. You should have three tables. One with all the members in it, another with all the conferences in it and another table that joins the two with memberId's that tell which conferenceId's they attended.
Ask this in the SQL Forum, cause right now, your code isn't workable until the database behind gets fixed.
|
|
|
|
|
How can i simultaneously Iterate and modify a .NET Queue i am using the following code:
<code>
Dim q As Queue = New Queue
Sub LoadValues()
q.Enqueue("mystr1")
q.Enqueue("mystr2")
q.Enqueue("mystr3")
executeloop()
End Sub
Sub executeloop()
If q.Count > 0 Then
For Each str As String In q
'do something with str
q.Dequeue()
MsgBox(q.Count.ToString())
Exit For
Next
executeloop()
End If
End Sub
</code>
And how can i add items to the Queue while iterating should i use SyncLock because I'm working on a Multithreaded application, and also not sure about the performance need your suggestions...
AliAmjad (MCP)
|
|
|
|
|
You cannot modify the collection as your enumerating it. You can modify the objects IN the collection, but you cannot modify the size of the collection (Add, Delete) at all in a For/Each loop.
|
|
|
|
|
Then what should I use for this purpose. I want to add items to the queue and at the same time want to manipulate it. Should I use collection object. And what's wrong with the code given above i know i cannot modify it while iterating but then what should i do to achieve the objective. Thanks for your time man.
AliAmjad (MCP)
|
|
|
|
|
Why are you using a Queue?? A queue is a list of items that's organized and manipulated on a First-In, First-Out basis.
What's the purpose of this collection?? The type of collection you use isn't so much dictated by what it's going to hold, but how the collection is going to be used.
If you want to manipulate items, adding them and removing them, then a List(Of T) would work, an array of strings, ArrayList, ...
|
|
|
|
|
Actually I'm working on a Distributed Web Crawler a Multithreaded application where each URL discovered will going to be added in a queue to implement the breadth-first search model. Many threads will access this queue and get the URLs from the top and then add the newly discovered URLs at the end of the queue and them remove the carwled URLs from the queue. Now what should i use in such a scenario. but when i implemented this logic i get this error "Collection was modified; enumeration operation may not execute".
AliAmjad (MCP)
|
|
|
|
|
Why are you enumerating them?? I don't see anything in this description that would justify it.
Well, now I see where your code came from. It's a modification of the sample code on MSDN.
You don't need a loop to dequeue items. The Dequeue method pops the top item off the queue and returns it an as Object. You have to cast the Object back to a String in order to use it.
Dim url As String = DirectCast(que.Dequeue(), String)
|
|
|
|
|
OKKK i get it but as i am in a multithreaded application then lots of threads will access this queue then should i use SyncLock or what else to ensure thread safety.
AliAmjad (MCP)
|
|
|
|
|
Wrap the queue object in a class that implements adding and dequeuing. Use the SyncLock on an object to make it thread safe.
|
|
|
|
|
Cooool thanks buddy but I'm going to save MD5 hash algorithm of URLs in hexadecimal form in the Queue so which Queue(of T) i should use so that It'll consume as little memory as possible because I am gonna Enqueue it with lots of URLs. Again thanks for your valuable time Dave.
AliAmjad (MCP)
|
|
|
|
|
AliAmjad wrote: but I'm going to save MD5 hash algorithm of URLs in hexadecimal form in the Queue so which Queue(of T) i should use so that It'll consume as little memory as possible because I am gonna Enqueue it with lots of URLs
That's nice. You better do some research on this first. MD5 is a one-way encryption hash. You can't reverse the hash and get the original URL back.
Forget hashing or compressing the URL. It's adding more complexity than you need, and unjustifiably so.
|
|
|
|
|
Yes it is a one-way encryption hash and that's why I'll use these for the reference of original URLs saved in a file in this way I'll be able to store many URLs in memory because a web crawler needs to maintain a huge list of URLs in memory and also i'll calculate the MD5 for the page itself for preventing the duplicate entries in index because its size is very small and always equal. So what you suggest on this. Should i go with MD5 or just manipulate raw URLs in memory but this way it will consume lot of memory (RAM).
AliAmjad (MCP)
|
|
|
|
|
I don't see the need for MD5 anything in your app. On top of that, with the skill level you've shown in the original post, this shouldn't even be a concern to you right now. Just getting the basic functionality should be. Queue up URL's, dequeue one, download it and move on. THEN you can add complex indexing and hashing to your database.
|
|
|
|
|
Thank you very much man for helping me out I'll surely implement this valuable Logic and analyze the results then I'll tell you about it.
Dave Kreskowiak wrote: The skill level you've shown in the original post
I consider myself as a beginner because I always try to grasp these important concepts and I've learned allot from you. What do you think about my Skill level? Am i capable enough to take this challenge of making a Distributed Web Crawler although I am up to some degree successfully able to achieve it. But still need a lot of guidance and help form people like you.
AliAmjad (MCP)
|
|
|
|
|
I want to access a file bit by bit.
My problem is that .Net as not "bit" datatype other than boolean.
It has bitarray which could be fine, I'm not sure.
I already managed to read the file by looping through all its bytes by using the ReadAllBytes method but now I want to be able to alter the bits and write them back to a file. This file could be anything, a good example is a JPG image.
How should I go about doing this?
|
|
|
|