CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Delphi >  VCL组件开发及应用

有谁会把下面的VB源代码翻译成Delphi的源代码?

楼主Linux2001(闭关开发中)2001-07-27 17:33:17 在 Delphi / VCL组件开发及应用 提问

Private   Sub   Command2_Click()  
          Dim   S   As   String,   Length   As   Long,   pos   As   Integer  
           
          S   =   String(1024,   0)  
          Length   =   GetProfileString("windows",   vbNullString,   "",   S,   Len(S))  
          S   =   Left(S,   Length)  
           
          List1.Clear  
          While   Len(S)   >   0  
                  pos   =   InStr(S,   Chr(0))  
                  List1.AddItem   Left(S,   pos   -   1)  
                  S   =   Mid(S,   pos   +   1)  
          Wend  
  End   Sub  
   
  Private   Sub   Command3_Click()  
          Dim   S   As   String,   Length   As   Long,   pos   As   Integer  
           
          S   =   String(1024,   0)  
          Length   =   GetProfileString(vbNullString,   vbNullString,   "",   S,   Len(S))  
          S   =   Left(S,   Length)  
           
          List1.Clear  
          While   Len(S)   >   0  
                  pos   =   InStr(S,   Chr(0))  
                  List1.AddItem   Left(S,   pos   -   1)  
                  S   =   Mid(S,   pos   +   1)  
          Wend  
  End   Sub  
  问题点数:47、回复次数:5Top

1 楼liubingqian(海风)回复于 2001-07-27 17:40:25 得分 0

不难啊!看两天Delphi的书也能改写啊。  
  程序有点儿长,这47分我不要了Top

2 楼Linux2001(闭关开发中)回复于 2001-07-27 17:42:56 得分 0

我看了好久的书都不会改耶!Top

3 楼trainbox(rain)回复于 2001-07-27 18:01:20 得分 27

Private   Sub   Command2_Click()  
  procedure   Command2_Click()  
  var  
      s:   string;  
      length1:   Integer;  
      pos1:   Integer;  
  begin        
          //S   =   String(1024,   0)  
          SetLength(s,1024);  
          Length1   :=   GetProfileString("windows",   '',   "",   S,   Length(S))  
          //S   =   Left(S,   Length)  
          s:=Copy(s,1,length1);  
           
          List1.Clear  
          //While   Len(S)   >   0  
          while   length(s)>0   do  
          begin  
                  //pos   =   InStr(S,   Chr(0))  
                  pos1:=Pos(s,chr(0));  
                  //List1.AddItem   left(S,   pos1   -   1)  
  List1.AddItem   copy(S,1,   pos1   -   1);  
                  //S   =   Mid(S,   pos   +   1)  
                  s:=copy(s,pos+1,1);  
          end  
  End;  
   
  下面类似  
  Private   Sub   Command3_Click()  
          Dim   S   As   String,   Length   As   Long,   pos   As   Integer  
           
          S   =   String(1024,   0)  
          Length   =   GetProfileString(vbNullString,   vbNullString,   "",   S,   Len(S))  
          S   =   Left(S,   Length)  
           
          List1.Clear  
          While   Len(S)   >   0  
                  pos   =   InStr(S,   Chr(0))  
                  List1.AddItem   Left(S,   pos   -   1)  
                  S   =   Mid(S,   pos   +   1)  
          Wend  
  End   Sub  
  Top

4 楼Linux2001(闭关开发中)回复于 2001-07-29 18:30:05 得分 0

to:trainbox()  
  你翻译的东东在delphi下会出错,比如S:=copy(s,1,length1)就不行Top

5 楼xzm2000(傻B)回复于 2001-07-29 18:58:47 得分 20

编译可以通过,但是运行会出错,呵呵  
  procedure   TForm1.Button2Click(Sender:   TObject);  
  var  
      s:   string;  
      Mylength:   longint;  
      Mypos:   integer;  
  begin  
          setlength(s,   255);  
   
          MyLength   :=   GetProfileString('windows',   nil,   '',   pchar(S),   Length(S));  
          S   :=   copy(S,   1,   MyLength);  
          ListBox1.Clear;  
          While   Length(S)   >   0   do  
          begin  
                  Mypos   :=   pos(S,   Chr(0));  
                  Listbox1.items.add(copy(S,   1,   Mypos   -   1));  
                  S   :=   copy(S,   Mypos   +   1,   length(s)   -   MyPos);  
          end  
  end;Top

相关问题

  • 一个对于高手来说不算难的抢分问题-----语法检测(这里有VB源代码,请高手翻译成Delphi的)
  • 关于VB的源代码移植到Delphi
  • 关于VB的源代码移植到Delphi
  • delphi的源代码怎么还没有VB多?delphi到底行不行了
  • VB源代码下载
  • 出售翻译软件源代码!!!
  • Delphi如何进行源代码管理?
  • Delphi实现源代码统计
  • 哪里有VB+SQL的源代码
  • 这里有许多VB源代码 wenchen2001.home.sohu.com

关键词

  • pos
  • wendend
  • vbnullstring
  • getprofilestring
  • additem
  • instr
  • chr
  • length
  • len
  • mid

得分解答快速导航

  • 帖主:Linux2001
  • trainbox
  • xzm2000

相关链接

  • Delphi类图书
  • Delphi类源码下载
  • Delphi控件下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo