AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

From VB to Delphi

Ein Thema von mohfa · begonnen am 4. Apr 2007 · letzter Beitrag vom 4. Apr 2007
Antwort Antwort
Seite 1 von 2  1 2      
mohfa

Registriert seit: 11. Feb 2007
97 Beiträge
 
Delphi 7 Enterprise
 
#1

From VB to Delphi

  Alt 4. Apr 2007, 08:11
I want to Translate this VB Code into Delphi :
Code:
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
many thanks
  Mit Zitat antworten Zitat
Benutzerbild von sirius
sirius

Registriert seit: 3. Jan 2007
Ort: Dresden
3.443 Beiträge
 
Delphi 7 Enterprise
 
#2

Re: From VB to Delphi

  Alt 4. Apr 2007, 08:56
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:
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;
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.
Dieser Beitrag ist für Jugendliche unter 18 Jahren nicht geeignet.
  Mit Zitat antworten Zitat
kalmi01
(Gast)

n/a Beiträge
 
#3

Re: From VB to Delphi

  Alt 4. Apr 2007, 09:34
@mohfa: if you have more than a small codesnippet, maybe that this tool is interesting to you.
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#4

Re: From VB to Delphi

  Alt 4. Apr 2007, 09:53
Zitat von kalmi01:
@mohfa: if you have more than a small codesnippet, maybe that this tool is interesting to you.
If you have money too much $ 599 ....
vbCr >> word wrap

greets
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#5

Re: From VB to Delphi

  Alt 4. Apr 2007, 09:57
The smallest Version should be enough ($99)
Markus Kinzler
  Mit Zitat antworten Zitat
Benutzerbild von sirius
sirius

Registriert seit: 3. Jan 2007
Ort: Dresden
3.443 Beiträge
 
Delphi 7 Enterprise
 
#6

Re: From VB to Delphi

  Alt 4. Apr 2007, 10:07
Zitat:
vbCr >> word wrap
So vbCr is #13.

You can change the following line to:
MSComm1.output:='0111' + #13;
Dieser Beitrag ist für Jugendliche unter 18 Jahren nicht geeignet.
  Mit Zitat antworten Zitat
kalmi01
(Gast)

n/a Beiträge
 
#7

Re: From VB to Delphi

  Alt 4. Apr 2007, 10:54
Zitat von EWeiss:
Zitat von kalmi01:
@mohfa: if you have more than a small codesnippet, maybe that this tool is interesting to you.
If you have money too much $ 599 ....
have look on the page and you will find:
Zitat:
You can freely download and install this software on your computer for evaluation:
what surprise
  Mit Zitat antworten Zitat
mohfa

Registriert seit: 11. Feb 2007
97 Beiträge
 
Delphi 7 Enterprise
 
#8

Re: From VB to Delphi

  Alt 4. Apr 2007, 11:17
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;
  Mit Zitat antworten Zitat
Nuclear-Ping
(Gast)

n/a Beiträge
 
#9

Re: From VB to Delphi

  Alt 4. Apr 2007, 12:51
You should have an eye on "TurboPower Async Pro" (http://sourceforge.net/projects/tpapro/) if you're looking for great port components. It does not really provide .Output and .Input but similar events.
  Mit Zitat antworten Zitat
mohfa

Registriert seit: 11. Feb 2007
97 Beiträge
 
Delphi 7 Enterprise
 
#10

Re: From VB to Delphi

  Alt 4. Apr 2007, 17:55
Sorry for this but please how can i translate this :

Code:
If InStr(1, Temp, ">") <> 0 Then
into Delphi
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:12 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz