
mark007
Avatar/Signature-
Posts
185 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by mark007
-
Still intrigued about whether anyone has any thoughts on this but I've rethought how things will work and come up with a different approach that I'm happier with anyway so thought I'd share. I've now set the library up so that the object can either be run asynchronously using the background work or synchronously without it - just set boolean in the call. If it is set to synchronously then progress is not updated and the library just gets on with the work and returns. If set async then it raises progress and completion events that a form using the library can make use of to update the progress. This feels quite a neat solution that should meet all the uses I have for the library. Effectively I've moved to the windows forms model I outlined earlier and am requiring the user of the library to implement a progress bar rather than having one built into the library.
-
Look into system.text.regularexpressions. Something like this would do it: Dim r As New System.Text.RegularExpressions.Regex("<title>(.+?)</title>") Dim m As System.Text.RegularExpressions.Match = r.Match(strText) System.Windows.Forms.MessageBox.Show("Title is: " & m.Captures(0).Value) Though note I've not tested. Mark
-
I'm putting together a class library and one of the functions within it is to update a local database with information obtained from a web service. I'd like to have the option to show the progress of this so have also put a small form in the library with a progress bar on it. Everything works but I'd like to make the progress bar more reliable and smoother. It's the same old problem of tying up the UI thread with an intensive operation so the UI updates aren't done. With a windows form application I'd have gone straight for a background worker. However with a class library this if different and I'm not sure how to approach this/whether it will work. Windows Form: Form Loads Async Process started on worker worker reports progress to form event form updates UI worker continues etc. Worker reports complete in form event Form updates UI The key point here is the form is loaded and listening for events throughout this. Class library: Create new object Call update sub on object update sub creates instance of progress bar form and starts async worker worker reports progress to object which updates progress form But: Update sub has completed by this point so the rest of the procedures in the code that instantiated the object will have ran by this point and the object may have been set to nothing. Therefore there is nothing to report the progress to. Does that make sense? I've not tested this and there could be some stuff going on int the .Net underbelly that ensure the object is kept alive until the worker has done but this doesn't feel right. What I effectively want to do is tell the code to stop what it is doing but keep updating the UI as appropriate until the worker has finished. Hope that explains the scenario. I guess to add a little more, the code will be initially called from within a COM interop component loaded in Excel. So: Excel Loads Excel calls load events on addin Addin references library Load events instaniate object in library and call update Any suggestions really apppreciated. Mark p.s. The workaround to this is to use 1 thread and form.refresh with every update - I suspect this slows things down quite a bit though.
-
This will do the first bit I think: [a-zA-Z0-9']*[a-zA-Z]+[a-zA-Z0-9']* :)
-
Thanks - that takes care of part3 quite nicely!
-
1. In asp.net you can store data in the cache safe in the knowledge that if memory is a problem some of it will be dumped. I am creating a dll that will serve as an Excel addin. Within it there will be times at which an extremely large number of calculations will be carried out. Alot of the intermediate results will be the same though so I wish to cache them under a string id of the calculation arguments. I could obviously do this using a hashtable easily enough however I was wondering if there is a built in cache that will manage situations when memory runs low as per in asp.net. 2. If anyone can think of a better=faster way of storing intermediate results other than storing under a key equal to a concatenated argument list I would appreciate it. 3. Finally how many concatenations are required before using a stringbuilder becomes faster? Cheers! :)
-
You just need to declare the button: Protected btnDelete as Button within your code behind then refer to btnDelete. If you are using Visual Studio.Net then this will be doen automatically.
-
Not sure if you are talking about Excel or not ut this Leagcy VB code might give you some ideas: http://www.thecodenet.com/articles.php?id=9
-
Well that was the point of the brackets i.e. you replace "(,)([^,]*)$" with " and $2" How does your's work Ingis? I can't say I follow it...
-
Ah ok, how about: "(,)([^,]*)$" :)
-
You don't need a regex for this. Just use: Dim s As String="Brown, Brown, Brown, Brown, Brown, Brown" Dim pos as integer=s.LastIndexOf(",") :)
-
Well you need to compare the code of the 2. I don't have a login at the code project so cannot download the spurce for the c# implementation. In particular you need to check that they use the same initialisation params.
-
Check out the body and HTMLBody properties of the MailItem class. :)
-
I can't say I know much about the algorithm but it would be useful to see how you are encrypting and attempting to decrypt. It may be a case of different default being used to seed part of the encryption.
-
Not had chance to try it bu the above looks good - thanks! :)
-
Would still be intrigued by replies but have solved it for now by adjusting the db to store binary data rather than strings and then have just assigned the byte array to the field.
-
Ok, this has been driving me insane for the last hour! I have the following function: Public Function EncryptPass(ByVal s As String) As String Dim encoder As New System.Text.UTF8Encoding Dim md5Hasher As New System.Security.Cryptography.MD5CryptoServiceProvider Return encoder.GetString(md5Hasher.ComputeHash(encoder.GetBytes(s))) End Function To encrypt passwords. However a particular password is returning a null byte after the hash has been replaced. I'm pretty sure this is what is causing my problems. Earlier in an area using an encrypted pass I was getting the following results in the command window: Me.m_Pass.length ==>12 me.m_Pass.toString.length ==>4 !!!! I finally traced it back to the hash returning the null byte which I think is where things are going wrong. Surely someone must have come across this before - any ideas for a solution? Thanks. :)
-
Opening a Word template.
mark007 replied to dylanmendes's topic in Interoperation / Office Integration
You could try and get the existing instance using getObject: Dim objWord as Object=Microsoft.VisualBasic.Interaction.GetObject(,"Word.Application") dim wdApp as Word.Application if objWord is nothing then wdApp=New Word.Application wdApp.Visible=true else wdApp=Ctype(objWord,Word.Application) end if This way you won't be creating a new instance if it alreday exists. :) -
Please post the code of this procedure: FitFreak.Exercise.btnAddExercise_Click(Object sender, EventArgs e)
-
Are you sure it was a value and not just the displayed text?
-
Make sure "Select Organisation Type" is a possible value.
-
Only approach I can think of is looping with IndexOf: Function CountWord(ByVal strText As String, ByVal strWord As String) As Integer Dim i As Integer Dim c As Integer = 0 i = strText.IndexOf(strWord) While i > -1 c = c + 1 i = strText.IndexOf(strWord, i + 1) End While Return c End Function :)
-
The easiest approach is probably just to catch the rror if it doesn't exist: try TextBox1.Text="Some text" Catch e as Exception 'textbox doesn't exist End try :)
-
Copying a transparent gif to the clipboard
mark007 replied to mark007's topic in Graphics and Multimedia
It's to be pasted as an icon on a toolbar in Excel. Thanks for the thoughts though... will see if it that can help at all. The whole code is something like: System.Windows.Forms.Clipboard.SetDataObject(f.PictureBox2.Image) b.PasteFace Where b is an Office CommandbarButton. -
Well said PlausiblyDamp. :)