|
Hey,
Sorry for the double awsner but i ran into this today
Dim filenames = My.Computer.FileSystem.FindInFiles("C:\", "text you want to find", True, FileIO.SearchOption.SearchAllSubDirectories)
arguments: 1. root folder, 2. searched text, 3. ignore capital, 4. seachoption.
returntype: a array of file locations (string)
|
|
|
|
|
Hello community,
I'm trying to read data from a website into a WinForms app, but all the samples I find use ASP.NET Namespaces. Using the HttpWebRequest type from the System.Net Namespace, I get into trouble with
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
Dim Param() As Byte = Request.BinaryRead(HttpContext.Current.Request.ContentLength)
Dim strRequest As String = encoding.ASCII.GetString(Param)
strRequest = strRequest + "&cmd=_notify-validate"
req.ContentLength = strRequest.Length throwing errors for the underlined methods, which are undefined. The rest seems to be ok.
Does someone have an idea how to replace the relevant line?
Thank you
Michael
|
|
|
|
|
Michael Schäuble wrote: throwing errors
Did you read the error messages? did you understand them? don't you think we could benefit and help you better when knowing the exact messages?
Did you add references to the namespaces you attempt to use? They get mentioned on the MSDN reference pages describing classes and methods.
|
|
|
|
|
I wrote: ... for the underlined methods, which are undefined Maybe I have to repeat my question in other words? I'll try...
The underlined methods (used in all the samples I could find) seem to be part of ASP.NET (used in these samples), which seemingly aren't supported in VB.NET. So the error message for these (unknown) methods would be e.g. "'Request' hasn't been declared.", which I also understand.
I'm looking for a workaround to retrieve data using non-ASP methods, e.g. from the System.Net Namespace, which I also referenced. Still they don't offer 'HttpContext', neither does the System.Web Namespace in VB (which has also been referenced).
modified 11-Jul-12 10:27am.
|
|
|
|
|
The classes and methods that are defined in the .NET Framework are organized in namespaces; you are allowed to use them no matter what language you are using, or what kind of application you are building. All you need to do is make sure you have proper references in your project (which gets done automatically for some, depending on the type of project you are building).
Example:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest(v=vs.80).aspx[^]
I've build quite a few WinForm apps that use System.Net in general and HttpWebRequest and other classes in particular. The most well known app using them is CP Vanity[^]. And I never had a need for HttpContext (which belongs to System.Web).
|
|
|
|
|
Hi Luc,
maybe you have to know that for me it's the first time I deal with web data retrieval, which is why I use code samples as orientation. In addition to that, I'm neither a programmer nor a student in the field who missed out on his homework, but professionally working in a completely different area with a bit of passion for programming in my leisure time. I hope you can see the huge difference – and I wish I wouldn't have to feel let down from your answers, which I do . I can assure you that I referenced System.Net as well as System.Web, read douzends of sources (for hours in my leisure time!) which I even partly understand, before I ask in the forum – still it's a new and very comlex field for me, and I suppose asking in a forum is appropriate considering the basic idea of a forum, right?
Luc Pattyn wrote: I never had a need for HttpContext I don't want to compete or insist in a particular way of solving the coding problem I face. Using HttpContext or the exact methods from the samples isn't relevant, I guess, but I need the alternative in order to reach the same goal.
You are the expert here and you might have a much better idea what the relevant line of code is doing. I could only face the fact that I obviously have to get a byte array from something (Request, HttpContext) that I don't know yet, seeing from the sample that HttpContext etc is part of the logic how others create that byte array. Still, my version of VS2010 doesn't know the underlined methods/objects/properties despite of the references.
Since you never had the need for HttpContext: How would you get the proper byte array?
OK, excuse this long and a bit off-topic personal post - maybe I'm getting old and too easily annoyed when feeling talked down to me. Just in case you're around Munich (Germany) eventually, I'll buy you a beer and answer your probable questions in my own field of expertise
|
|
|
|
|
Hi Michael,
this is unlike you. This time around, you haven't explained in any detail what it is you are attempting ("read data from a website"), and what the symptoms are ("throwing errors"); all I could do is make a wild guess, hence the "add reference" suggestion, and now you say that wasn't it, and no new information. This way I can't help you, and I doubt anyone can. Please provide ample information (goals, context, code, detailed observations) if you want a helpful answer.
|
|
|
|
|
OK, so I give up the thought of having you others deal with "only one line"...
I'm attempting to get IPN (Instant Payment Notification) transaction data from PayPal into a WinForm App for further processing (like shipping management, tax etc.). You can download the PayPal sample code here.
As soon as you create a new Windows Forms project, paste the sample code into a new Form (which can't then inherit System.Web.UI.Page) and add "Imports System.Text" (for the streamwriter) you'll surely see what I mean: The line which I had initially posted is the only line which will prevent you from debugging... letting you know that 'Request' and 'HttpContext' aren't declared. "Imports System.Web" doesn't change that.
Meanwhile I might have found a problem with the whole IPN approach: The application obviously has to be online 24/7 in order to receive the event notifications once they are sent. As a result I might have to mess with the PayPal API
All I want is a list of the transaction details to be downloaded – but without the necessity of website integration / ASP.NET (the webhost has Linux). But it's kinda rough for me .
|
|
|
|
|
OK, I looked into this matter somewhat closer, and here are my findings and suggestions, they may not suffice to get anything fixed though.
1.
HttpContext is a class inside System.Web, adding a reference to that and including an Imports should take care of it.
2.
Request is more complicated; you get it for free in an ASP.NET application, as a member of the Page.
And it also exists inside HttpApplication (which requires 3.5 or above), not sure that could help.
3.
The ZIPped code is performing a POST as soon as a page loads; if I understand correctly, it is the app requesting a page, then when that loads, posting the last request with something added; so you probably don't need the incoming request (as it must equal the request you launched just before), you could probably post right away what it is you need posted.
4.
My regular POST code looks like this in C#, the same could be handled in VB.NET; inputs are two strings (URL and postMessage):
HttpWebRequest req=(HttpWebRequest)WebRequest.Create(URL);
#if WITH_NETWORK_CREDENTIAL
#endif
if (postMessage!=null) {
byte[] bytes=Encoding.UTF8.GetBytes(postMessage);
int length=bytes.Length;
req.ContentLength=length;
req.ContentType="application/x-www-form-urlencoded";
req.Method="POST";
Stream stream=req.GetRequestStream();
stream.Write(bytes, 0, length);
stream.Close();
}
HttpWebResponse resp=(HttpWebResponse)req.GetResponse();
using (Stream stream=resp.GetResponseStream()) {
}
5.
As you already said, I'm afraid a WinForms app isn't the right environment to perform IPN operations. I once looked into IPN from a web shop point of view, which meant the server side. The server would always be up and ready to react on PayPal's notifications. At that time, I browsed a WROX book "Web APIS with PHP" which discussed a number of API's including PayPal's, from the server's point of view; and obviously the examples all use PHP, not any of the .NET languages. However I never implemented any part of the PayPal functionality, and
I never became really familiar with the protocols.
6.
There are quite a lot of PayPal articles here at CP, and yes most if not all talk about ASP.NET; you might get some help by finding the closest match to what you want, then ask in the article's forum.
|
|
|
|
|
WOW - thank you for digging in so deep... that's actually what I wanted to prevent you forum experts from And: You also made me really happy by not supplying a Google link which supplies 100 perfect samples
1) I could finally find it and add a reference after changing the target framework from ".NET 4 Client Profile" to ".NET 4". Before, using the default Client Profile (by now I never realized a difference), the System.Web namespace only offered 2 AspNet-Classes and an AspNet-Enum, so that I'd say it's been hidden extremely well
2) After following your hint with an additional "Imports System.Web.HttpApplication" a slight change first seemed to make it:
Dim httpReq As System.Web.HttpApplication = Nothing
Dim Param() As Byte = httpReq.Request.BinaryRead(HttpContext.Current.Request.ContentLength) I could at least start debugging... immediately running into a 'NullReferenceException' in the same line Due to 5) I finally decided to not go on debugging this one, but rather dig into the PayPal Api.
3) The incoming request has to be sent back identically and with an addition for security reasons. If both are identical, PayPal only sends "VERIFIED" or otherwise "INVALID". That's part of their procedures.
4) Thank you for the snippet – I'll keep it for possible future challenges so I wouldn't have to bother you guys
5) For any future challenges of yourself you might be interested in this brand-new information. After reading up and down the whole web for days, realizing that even experienced programmers don't really want to deal with the PayPal API, I immediately checked a sample project out... and seem to be on a very good way!!! The sample I meanwhile adapted is still using ASP.NET, but in the browser I can obviously access the needed variables already (using my Sandbox test accounts).
6) Doing that was part of my "homework" while before asking in the forum...
I'll surely have to master a few challenges before having my WinForms solution running (most likely with the same sort of problems finding the appropriate namespace), but I'm more confident now. Still thank you for consideration – for now I wish you a fond good night!
Regards
Mick
|
|
|
|
|
I'm glad you're making progress, and I do hope you will eventually write a CP article on the subject, consolidating all your efforts into a useful contribution.
|
|
|
|
|
Hello, everyone.
I met a problem when inversing a matrix with application.worksheetfunction.MInverse in Excel 2003.
I found there is a matrix scale limit for the function of MInverse, the largest matrix is 52*52.
I wrote some codes and tried to solve this problem, but it is too slow to bear.
Therefore, how to efficiently inverse a very large matrix? Can you show me some sample codes?
Thanks for your any useful hints.
|
|
|
|
|
|
As Wikipedia[^] says, there are a couple of ways to invert a matrix. I personally prefer the LU decomposition, it has never failed me (mostly in C), and I used it for matrices with size of several hundred.
How big is your matrix? The complexity is O(n^3) so there may be practical limits.
When the matrix is sparse (e.g. when simulating electronic networks), you can apply special techniques that typically bring it down to O(n^2).
|
|
|
|
|
i need source code that show application that run in the window with a cpu usage in visual basic6
Please help me
my email:ali.boy1994@yahoo.com
topboy74@yahoo.com
tanks
|
|
|
|
|
First, it doesn't work that way around here. We will NOT just hand over an entire project to you.
Second, you're asking for VB6 source. VB6 is dead, has been be fore quite a long time, and support for it is quickly dying with it.
We WILL help you with writing your own code, just don't expect a lot of help with VB6.
Oh, and nobody cares what your email address is except spammers and their little search bots. NEVER put it in a public forum.
|
|
|
|
|
aliali74 wrote: i need source code that show application that run in the window with a cpu usage
in visual basic6
I am not sure that I still have VB6 available. But I will try and look for it. How much are you paying for this project by the way?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
I would like to add a CountChanged event to the standard ListBox control. Is it possible to access the properties of a standard MS control in this way and if so could it be done runtime or would I need to create a custom control? I have a basic understanding of the event raising and handling protocol but I'm scratching my head on how to link the property. Any pointers gratefully received.
|
|
|
|
|
If you use VB2010 (also Express Version)you can extend or change standard methods – and I guess it's the same with controls – by using 'Extension Methods'. If you google for that, you'll find plenty of information and sample code. In VB the Extension Methods have to be defined in a module, not a class.
|
|
|
|
|
|
Thanks for the suggestions guys but neither really fits the bill. I could possibly write extension methods for all the possible ways that the number of items in a List Box and set off an event in each one but that seems rather cumbersome and subject to possible errors. Extender Provider adds properties to controls but I don't need another property, I need to monitor an existing one.
The intention is to have an event trigger every time that the count of list items changes for any reason. Such an event could be used to warn when a list of attendees becomes oversubscribed, for example. Now clearly it is possible to monitor the ListBox.Count property using a timer, for example, which probably is more than good enough for nearly all uses. I just wondered whether it was possible to raise an event directly. Guess the answer's, not.
|
|
|
|
|
Member 9082365 wrote: The intention is to have an event trigger every time that the count of list
items changes for any reason
Actually, this is a piss-poor idea. A ListBox control should not be the "authoritative" collection of items, such as your list of attendees. A dedicated collection should be the one that controls this and either raises its own event or throws an exception of the collection is considered full. The ListBox should be used as it was designed, as a visual representation of the backing collection, nothing more.
Your idea is not quite as simple as creating your own version of ListBox with this little functionality added. The ListBox Items collection is a seperate class, called ObjectCollection I believe. You'd have to inherit from ObjectCollection, add your CountChanged event to it, the create your own ListBox implementation, changing out the Items collection with one that uses your new ObjectCollection implementation, handle the ObjectCollection.CountChanged event you made, and, finally, the ListBox would have to expose it's own CountChanged event that fires whenever the underlying ObjectCollection.CountChanged event was raised.
...or some variant thereof. But, the basic concept doesn't change from this.
|
|
|
|
|
Well thanks for the lecture. It was only an off-the-top-of-my head example (I don't know what the initial enquirer has in mind) but feel free to belittle us all. We so love it.
As for the actual information, it is much as I suspected. Something I'll maybe take on when I've a few spare days (or weeks!)
|
|
|
|
|
I used something similar for a listview. If you still need a solution i can dig for it and post some snippets here... i guess that the listbox doesn't work that much different.
The thing gave me also a few long hours to search for a solution...
|
|
|
|
|
Am in the middle of developing a window app when i got stuck.the tools used are as follows combobox,numericbox,textbox and a radio button.Actually what i wanted to achieve is small inventory.Meaning that whenever i click on the value in the combobox as against that of numericbox it will automatically subtract from stored values.
Pls help me out tanks
|
|
|
|
|