First off let me say if this is in the wrong forum i sincerely apologize. Since most people move from VB6 to Delphi, I figured this would be the proper place to put this question.

The code I did in delphi works without any problems whatsoever. Because I want to have this do the exact same thing in VB6, I am running into some problems of course...

this is what I have done thus far... i dont get any errors, but I also dont get the result I need either. The VB6 code for each 'sub' is above the delphi code for that procedure.

Private Sub Command1_Click()
Form1.Visible = True
Form3.Visible = False
' work on actually unloading form3 instead of hiding it
End Sub

'********** Delphi Equivalent *****************
'procedure TAuth.Button1Click(Sender: TObject);
'begin
'MainForm.Visible := True;
'Auth.Destroy;
'end;
'*********************************************************
'*********************************************************


Private Sub Form_Load()
Form3.Height = 1410
Form3.Width = 1695
Command1.Visible = False
Label1.Caption = "Checking..."
Text1.Text = "abc123"
Winsock5.Close
'Winsock5.Connect "A-WEBSITE.COM", "80"
Winsock5.RemoteHost = "A-WEBSITE.COM"
Winsock5.RemotePort = "80"
Winsock5.Connect
End Sub

'********** Delphi Equivalent *****************
'procedure TAuth.FormCreate(Sender: TObject);
'begin
'Button1.Visible := False;
'VerifySerial.Caption := 'Authorizing...';
'Edit1.Text := 'abc123';
'clientsocket1.Active := False;
'clientsocket1.Port := 80;
'clientsocket1.Host := 'A-WEBSITE.COM';
'clientsocket1.Active := True;
'end;
'*********************************************************
'*********************************************************

Private Sub Winsock1_Connect()
Dim s As String
s = "GET [url]http://A-WEBSITE.COM/index.html[/url] HTTP/1.0" + "#$0D#$0A" + "Accept: */*" + "#$0D#$0A" + "Accept: text/html" + "#$0D#$0A" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" + "#$0D#$0A" + "#$0D#$0A"
Winsock5.SendData (s)
End Sub

'********** Delphi Equivalent *****************
'procedure TAuth.ClientSocket1Connect(Sender: TObject; Socket: TCustomWinSocket);
'Var
's : string;
'begin
's := 'GET [url]http://A-WEBSITE.COM/index.html[/url] HTTP/1.0' + #$0D#$0A + 'Accept: */*' + #$0D#$0A + 'Accept: text/html' + #$0D#$0A + 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' + #$0D#$0A + #$0D#$0A;
'clientsocket1.Socket.SendText(s);
'end;
'*********************************************************
'*********************************************************



Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim buffer As String
Pause (1500)
buffer = Winsock1.GetData
    If pos("abc123", buffer) > 0 Then
    Label1.Caption = "Authorized!"
        Else
        Label1.Caption = "NOT Authorized!"
            End If
    If Label1.Caption = "Authorized!" Then
    Form3.Height = 2130
    Command1.Visible = True
        Else
        Label1.Caption = "Denied!"
        Command1.Visible = False
        Pause (1500)
        UnloadMe
    End If
    End Sub
            
'********** Delphi Equivalent *****************
'procedure TAuth.ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
'Var
'buffer : string;
'begin
'Sleep(1500);
'buffer := clientsocket1.Socket.ReceiveText;
'if pos('abc123', buffer) > 0 then
'VerifySerial.Caption := 'Authorized!'
'Else
'VerifySerial.Caption := 'NOT Authorized!';
'if VerifySerial.Caption = 'Authorized!' then
'begin
'Auth.Height := 135;
'Button1.Visible := True;
'End
'Else
'begin
'if VerifySerial.Caption =  'Not Authorized!' then
'VerifySerial.Caption := 'NOT Authorized!';
'Auth.Caption := 'Denied!';
'Button1.Visible := False;
'Sleep(1500);
'Application.terminate;
'end;
'end;
'*********************************************************
'*********************************************************

Any help would certainly be appreciated... Again, If this needs to be somewhere else, I do apologize in advance.

Thank you. :)

Hello LizR,

The difference is that I dont get anything at all. It doesnt seem to do anything except for sit there checking to see if the info in the code matches the info at the website i have set up.

Nothing happens at all. :(

welp i hope someone can help me, i think i jes have the syntax wrong. anyone is certainly welcome to put their 2 cents in. :) Also, wysiwyg... i dont have any public/global variables set for this.

Do remember not all of us are in your timezone, and do have to sleep from time to time..

OK, looking at the code the first thing to do would be to check your winsock data arrival procedure is actually being called, and if so, what data you get.

Data doesnt always arrive as 1 chunk, which doesnt seem tobe accounted for in that proceedure overly well. In that the data could be split over a packet.

As long as the routine is being called you'll be able to track down why its not working - why you're moving to a language (eg vb for win32) which was dropped by MS.. im unsure, but, its your call.

You'll need to tell us if the data is returning the way you'd expect it to.

The other thing would be you've told the code to run in the onload not a button press so it snot goign to run on demand.

Thanks Lizr,

I dont really know how to find out what I am "getting back" from the program when i run it.

I think the line sub that isnt working right is this one:

Private Sub Winsock1_Connect()
Dim s As String
s = "GET http://A-WEBSITE.COM/index.html HTTP/1.0" + "#$0D#$0A" + "Accept: */*" + "#$0D#$0A" + "Accept: text/html" + "#$0D#$0A" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" + "#$0D#$0A" + "#$0D#$0A"
Winsock5.SendData (s)
End Sub

The Delphi code i used that 'does' work is as follows:

procedure TAuth.ClientSocket1Connect(Sender: TObject; Socket: TCustomWinSocket);
Var
s : string;
begin
s := 'GET http://A-WEBSITE.COM/index.html HTTP/1.0' + #$0D#$0A + Accept: */*' + #$0D#$0A + 'Accept: text/html' + #$0D#$0A + 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' + #$0D#$0A + #$0D#$0A;
clientsocket1.Socket.SendText(s);
end;

I have no idea idea how this converts into a VB6 environment however.... so if you, or anyone else knows what I would need to do to make this delphi procedure work as a VB subroutine, that would likely solve this problem for me completely :)

Basically all I need is the proper way to read a specific 'password' off of a site that i created to protect programs that i write. so the procedure basically looks for a certain sequence of characters. If they are there on the website, then the program will open. if not, it wont open.

Thanks for any help. :)

Put a break point in, add a watch to th value.. basic stuff.. thats how you tell whats in it.

thanks for the help with the watch to see what is happening. It looks like it does connect to the remost host because it returns an ip for that host. but it seems to get stuck in the subroutine.
So, im not sure what to do at this point. There isnt any reason i can see why it should do this. I know I must be doing something wrong or it would work.

Any suggestions are apprciated. :)

which one does it get stuck in?

Only thing I can think of is
"#$0D#$0A" + "#$0D#$0A"


by putting in the " marks you're turning them to strings.. which isnt what you want. so its possibly not returning the data you want.

I think you have a good point... But if I dont put them within the "" , it returns an error as follows:

Compile Error:

Expected: expression

If you know of a way for a program written in VB6 to locate a specific pattern of text from a website and return a value of true or false (i.e. if it is there = true, if not there = false) to allow the program to run, I am all ears... (or eyes in this case... hehe) In this case, I am checking to see if the persons HDD volume ID is there or not.

thanks for your help once again. :)

thats because vb doesnt do the #$ notation.. I believe its something like vbCrLf .. but I dont do vb, its pointless.

and I believe VB still has a pos function where you can test if its > 1 or not.. check the helpfile

i think putting that in actually worked! lol! niiiiiice!

but now im stuff in the data retreival part.. i need to look into that before i ask more questions.... If you care to... you could look into what i did wrong on that part... :) I think that did it tho... it made it through the procedure** ermm the subroutine. :)

thanks a million... now for the next part.. im sure you can do it LizR :)

Debugging is always the answer
Follow the data you get back, look at its values, look at what your code does.

I dont have vb6 to put it in. (or rather its around on a cd somewhere, but I am not loading it)

ok well, i guess ill take the remaining bit of it to the VB forum. If you are interested in helping me figure out how to parse the proper characters, I think the only problem is a matter of syntax at this point LizR.

Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
Dim buffer As String, S As String, TmpData As String
Pause 1.5
buffer = Winsock2.GetData(TmpData, vbString)
    If InStr(1, "abc123", buffer) > 0 Then

The line: buffer = Winsock2.GetData(TmpData, vbString)

seems to be the only part the is keeping this code from parsing the text. As always, thank you and any help is certainly appreciated. :)

Believe me, I have tried... Many times LizR. Either I don't know how to do debugging effectively, or I am just plain stupid, or a combinatioin of both (the latter is most likely).

This tends to be frustrating... :( I am so close to getting this. :(

Put a break point on the first line in your data retrieval code
Add a watch to the value of the data returned eg buffer
Step through the code.

Most likely the issue is the value of buffer, if not, make a dummy app and play around with string functions till you find the one you want and how to use it

It doesnt matter if I add a breakpoint to it or not when the syntax isnt right.

I know you are trying to help, but the error is that of syntax. Ill just try to get help in the VB section. Thanks for your efforts.

This article has been dead for over six months. Start a new discussion instead.