Title: Porting usefull functions from VB to Delphi.
Question: I needed to translate a complex program from VB to Delphi: that unit saved me!
Answer:
Unit VBFunctions;
Interface
Uses
Windows, Classes, SysUtils;
Function Left( What : String; Count : Integer ) : String;
Function Right( What : String; Count : Integer ) : String;
Function Mid( What : String; Index, Count : Integer ) : String;
Function InStr( Start : Integer; SubStr, Str : String ) : Integer;
Function Len( Str : String ) : Integer;
Function RTrim( Str : String ) : String;
Function LTrim( Str : String ) : String;
implementation
Function Left( What : String; Count : Integer ) : String;
Begin
Result := Copy( What, 1, Count );
End;
Function Right( What : String; Count : Integer ) : String;
Begin
Result := Copy( What, Count, MaxInt );
End;
Function Mid( What : String; Index, Count : Integer ) : String;
Begin
Result := Copy( What, Index, Count );
End;
Function InStr( Start : Integer; SubStr, Str : String ) : Integer;
Var
tmpStr : String;
Begin
tmpStr := Copy( Str, Start, MaxInt );
Result := Pos( SubStr, Str );
End;
Function Len( Str : String ) : Integer;
Begin
Result := Length( Str );
End;
Function RTrim( Str : String ) : String;
Begin
Result := TrimRight( Str );
End;
Function LTrim( Str : String ) : String;
Begin
Result := TrimLeft( Str );
End;
End.