![]() |
From VB to Delphi
I want to Translate this VB Code into Delphi :
Code:
many thanks
Private Sub cmdTP_Click()
MyStrg = "" MSComm1.Output = "0111" & vbCr MyStrg = MSComm1.Input Text1.Text = MyStrg Temp = Mid(MyStrg, 12, 3) If InStr(1, Temp, ">") <> 0 Then 'If Mid(MyStrg, 12, 1) = ">" Then B1 = Mid(MyStrg, 7, 2) 'Convert slection into decimal B2 = ("&H" & B1) 'calulate it TP = (B2 / 256) * 100 TP = Format(TP, "0") 'output lblTP.Caption = TP & " %" Else 'Do Nothing End If End Sub |
Re: From VB to Delphi
I suppose that MSComm1, Text1 and lblTP are special components. The last one could by a label
I'm not sure. but maybe this could be a translation:
Delphi-Quellcode:
I don't know if some of those temporal variables are also used global. vbCR is either a global variable too or it is a special constant.
procedure cmdTPButtonClick(...); //whatever the click-event is...
//defining temporal/local variables var myString:string TP_string:string; Temp:string; TP_float:double; B1:string; B2:double; begin myString:=''; //This is not neccessary if this variable stays local. MSComm1.output:='0111' + vbCR; // vbCR? myString:=MSComm1.Input; Test1.Text:=myString; Temp:=MidStr(myString,12,3); if pos('>',myString) > 0 then begin B1:=MidStr(MyString, 7, 2); B2:=strtoint('$'+B1); TP_float:=B2/256*100; TP_string:=inttostr(round(TP_float)); lablTP.Caption:=TP_string + ' %'; end; //Else - part is empty end; |
Re: From VB to Delphi
@mohfa: if you have more than a small codesnippet, maybe that
![]() |
Re: From VB to Delphi
Zitat:
vbCr >> word wrap greets |
Re: From VB to Delphi
The smallest Version should be enough ($99)
|
Re: From VB to Delphi
Zitat:
You can change the following line to:
Delphi-Quellcode:
MSComm1.output:='0111' + #13;
|
Re: From VB to Delphi
Zitat:
Zitat:
|
Re: From VB to Delphi
MSComm1.output:='0111' + #13;
** MSComm : is a VB Common ports components my question is is there any similar Delphi Component(s) with the same Properties and events , especially : .output and .input MSComm1.output:='0111' ; myString:=MSComm1.Input; |
Re: From VB to Delphi
You should have an eye on "TurboPower Async Pro" (
![]() |
Re: From VB to Delphi
Sorry for this but please how can i translate this :
Code:
into Delphi
If InStr(1, Temp, ">") <> 0 Then
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:22 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz