Converting source from Delphi to VB-VBForums
Results 1 to 2 of 2

Thread: Converting source from Delphi to VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    3

    Question Converting source from Delphi to VB

    Hello,

    It's been a while (10+ years) when I last coded anything small in Delphi and most of last 5-6 years I have been doing just VB6.
    So I am looking for some help of anyone to convert the following source code from Delphi into VB.

    Actually the source code of Delphi is sending and receiving come commands over LAN using TCP and in binary/decimal format. Although there are plenty of comments in code, I am still unable to get it into right point as the Delphi is working and my VB code is not working as I am not getting the right values.

    Code:
    -------------------------------------
    We use TrtcTCPserver from http://www.realthinclient.com/
    to listen in 2666 port like the above.
     a:= TrtcTCPserver.create(Nil)
     a.serverport := 2666;
     a.listen;
    
    this is the code for ongetdata event from TrtcTCPServer 
    // *****************************************
    procedure TNovo.DoOnGetData(Sender: TRtcConnection);
    var
      S: AnsiString;
      nId,nAmount,nBet:Integer;
      isStartPressed:Boolean;
     begin
     
       if not Sender.inMainThread
       then  Sender.Sync( DoOnGetData )               
       else begin
         s := Sender.Read;                       <== here get the connection data
         BinaryToValues( s , nId , nAmount );    <== and convert it to integer
         // right after the client connect to server
         // send to sender ( in binary ) decimal 1
         // a use a function like this Sender.Write( ValuesToAnsi(1,0)
         // after that client reply with the following..
        
         Case FSendFlag of  
            ssConnected:  // sends 1<2 ,0<1, 5<6 , 6<7   
            begin
              Case nId of
                2: begin  <== if we receive 2 send 0 and wait for 1
                     Sender.Write( ValuesToAnsi(0,0) );  // waits for 1
                   end; 
                1: begin   <== if we receive 1 send 6 and wait for 6
                          // here the var nAmmount = current credits 
                     GM.Credits := nAmount;
                     Sender.Write( ValuesToAnsi(5,0) ); // waits for 6
                   end;
                6: begin  <== if we receive 6 send 6 and wait for 7
                        // here the var nAmmount = Total IN 
                     GM.LocalIn := nAmount;
                     Sender.Write( ValuesToAnsi(6,0) ); // waits for 7
                   end;
                7: begin <== if we receive 7 send nothing and terminate the chat
                     // here the var nAmmount = Total OUT
                     GM.LocalOUT := nAmount;
                     FCheckTimer.Enabled := True;
                     FSendFlag := ssIdle;
                   end;  
              end;
            end;
           
            // if you send 0 like this Sender.Write( ValuesToAnsi( 0 , 0 ) )
            // you get result like this nid =1  nAmount = current credits
            ssCheck:  // sends 0 < 1
            begin
               if nID=1 then begin
                  OldCredits := 0;
                  GM.Credits := nAmount;
                 FSendFlag := ssIdle;
               end; 
            end;
    
            // to insert credits to send 2 and the credits to be inserted
            // like this Sender.Write( ValuesToAnsi( 2 , 2000 ) )
            // this insert 2000 credits and if everything is ok returns 3
           
            ssIN:  // sends 2, nAmount < 3   , 0<1 
            begin
              Case nId of
                3: begin  <== then i resend 0 in order to recheck the credits
                     Sender.Write( ValuesToAnsi( 0 , 0 ) ); // waits for 1
                   end; 
                1: begin   
                     OldCredits := nAmount;
                     GM.Credits := nAmount;
                     FSendFlag  := ssIdle;
                   end;
              end;
            end;
            // to remove credits you must send 4 and you get reply 5
            ssOUT:  // sends 4< 5  , 0<1 
            begin
              Case nId of
                5: begin <== if deleted check egain the current credits
                     Sender.Write( ValuesToAnsi( 0 , 0 ) );
                   end;
                1: begin
                     OldCredits  := nAmount;
                     GM.Credits  := nAmount;
                     FSendFlag  := ssIdle;
                   end;
              end;
            end;
         end;
      end;   
    end;
    **************
    Thanks in advance for all who take time to read this and to help me!

  2. #2

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    3

    Re: Converting source from Delphi to VB

    nobody available for some help ? Please ?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.