|
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
|
|
|
|
|
Quote: Am in the middle of developing a window app when i got stuck
could you be a bit more specific?
perhaps show a bit of code to where you get stuck or witch error you hang on.
|
|
|
|
|
samfrancis wrote: it will automatically subtract from stored
Okay so go right ahead, you have my permission. Please come back and ask questions when you get stuck.
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
|
|
|
|
|
It would be somewhat like this:
Private Sub myCombo_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) _
Handles myCombo.SelectedIndexChanged
Me.myNumeric.Value += CDbl(myCombo.SelectedIndex) ' add index value
End Sub
|
|
|
|
|
hai guys..
i am having trouble with vb.net..please anybody tell me that how to copy a file to system directory. while i'm tried to copy using the command "file.copy", it is says "you need administrative privilage to access system directory"..
thanx in advance
|
|
|
|
|
info4shajeer wrote: you need administrative privilage to access system directory
If you do not have an administrator account then you cannot do it. If you do have an administrator account then modify your program's properties to run as administrator, as described here[^].
|
|
|
|
|
|
I have a cpp code, I had difficulty in doing the conversion to visual basic 6, is there anything that can help me. The following sample cpp program is:
// Defined to disable deprecated functions warning in Visual C++ 2005
#define _CRT_SECURE_NO_DEPRECATE 1
#include <windows.h>
#include <stdio.h>
#pragma pack(1) // set byte packing
typedef struct {
unsigned __int32 bLength;
char szSerNum[9];
char szProdName[9];
unsigned __int64 MinFreq;
unsigned __int64 MaxFreq;
struct {
unsigned __int32 ExtRef:1;
unsigned __int32 FMWEnabled:1;
unsigned __int32 Reserved:30;
} Features;
} RADIO_INFO2;
#pragma pack() // set back the default packing
// G305 API function type declarations
typedef int (__stdcall *FNCOpenRadioDevice)(int iDeviceNum);
typedef BOOL (__stdcall *FNCCloseRadioDevice)(int hRadio);
typedef BOOL (__stdcall *FNCGetInfo)(int hRadio,RADIO_INFO2 *info);
typedef BOOL (__stdcall *FNCSetAtten)(int hRadio, BOOL fAtten);
typedef BOOL (__stdcall *FNCSetPower)(int hRadio, BOOL fPower);
typedef BOOL (__stdcall *FNCSetAGC)(int hRadio, int iAGC);
typedef BOOL (__stdcall *FNCBlockScan)(int hRadio,DWORD *Freqs,size_t Count,int StopSquelchRaw,DWORD FeedbackTime,HWND WinHandle,DWORD Msg);
typedef BOOL (__stdcall *FNCStopBlockScan)(int hRadio);
typedef BOOL (__stdcall *FNCCodecStart)(int hRadio,void (__stdcall *CallbackFunc)(void *),void *CallbackTarget);
typedef BOOL (__stdcall *FNCCodecStop)(int hRadio);
int main(int argc, char* argv[])
{
// load the G3 API library
HMODULE dll=LoadLibrary("wrg305api.dll");
if (!dll) {
puts("WRG305API.DLL not found !");
return 0;
}
// link G3 API functions
FNCOpenRadioDevice OpenRadioDevice=(FNCOpenRadioDevice)GetProcAddress(dll,"OpenRadioDevice");
FNCCloseRadioDevice CloseRadioDevice=(FNCCloseRadioDevice)GetProcAddress(dll,"CloseRadioDevice");
FNCGetInfo GetInfo=(FNCGetInfo)GetProcAddress(dll,"GetInfo");
FNCSetAtten SetAtten=(FNCSetAtten)GetProcAddress(dll,"SetAtten");
FNCSetPower SetPower=(FNCSetPower)GetProcAddress(dll,"SetPower");
FNCSetAGC SetAGC=(FNCSetAGC)GetProcAddress(dll,"SetAGC");
FNCBlockScan BlockScan=(FNCBlockScan)GetProcAddress(dll,"BlockScan");
FNCStopBlockScan StopBlockScan=(FNCStopBlockScan)GetProcAddress(dll,"StopBlockScan");
FNCCodecStart CodecStart=(FNCCodecStart)GetProcAddress(dll,"CodecStart");
FNCCodecStop CodecStop=(FNCCodecStop)GetProcAddress(dll,"CodecStop");
if (!GetInfo || !BlockScan || !StopBlockScan) {
puts("Not all needed API function not found. Please update the WR-G305 software!");
FreeLibrary(dll);
return 0;
}
// open the first available radio
int hRadio=OpenRadioDevice(0);
if (!hRadio) {
puts("No G305 device could be opened !");
FreeLibrary(dll);
return 0;
}
// obtain the radio info to be able to detect USB connected receivers
RADIO_INFO2 radio_info;
radio_info.bLength=sizeof(radio_info);
GetInfo(hRadio,&radio_info);
// check for USB receiver
BOOL USB_recv=FALSE;
if (!memcmp(radio_info.szProdName,"G3USBv",6)) {
puts("USB receiver detected");
USB_recv=TRUE;
}
// set Power,AGC and Attenuator
if (SetPower(hRadio,TRUE)) puts("The device is turned ON");
else puts("The device failed to turn ON");
if (SetAtten(hRadio,FALSE)) puts("The attenuator is OFF");
else puts("The attenuator failed to turn OFF");
if (SetAGC(hRadio,3)) puts("The AGC is FAST");
else puts("The AGC failed to switch");
// for USB receivers codec streaming must be started
if (USB_recv) CodecStart(hRadio,NULL,NULL);
// prepare the buffer for the blockscan from 600 to 800 kHz
size_t i;
DWORD Freqs[101]; // buffer for frequencies to scan
for (i=0;i<=100;i++) Freqs[i]=(DWORD)(88000000+200000*i);
// let's start the blockscan with 1001 frequencies, don't stop by Squelch.
// no feedback (after a million ms), don't send us the buffers, we'll check that all
if (BlockScan(hRadio,Freqs,101,256,1000000,NULL,0)) puts("The block scanning started..");
else puts("The block scanning failed to start");
puts("Scanned data:");
for (i=0;i<=100;i++) {
while (Freqs[i]>255) Sleep(10); // the frequency is not scanned yet, we have to wait
//printf("Freqsss: %ld\tRAW:%ld\n",88000000+200000*i,Freqs[i]);
printf("Freqsss: %ld\tRAW:%ld\n",Freqs[i]);
}
// the block scanning is over
if (StopBlockScan(hRadio)) puts("Block scanning is stopped");
else puts("Block scanning couldn't stop");
// for USB receivers codec streaming must be stopped
if (USB_recv) CodecStop(hRadio);
// close the device handle
if (CloseRadioDevice(hRadio)) puts("The device is closed properly");
else puts("The device failed to close");
// free the G3 API library
FreeLibrary(dll);
return 0;
}
|
|
|
|
|