我是一个delphi初学者,在实验的时候书里的两个语句
label1.text:= inputbox('输入提示'+'请输入问候名'+'world');

showmessage('颜色显示失败');
出错
我不知道是我漏了什么还是书上错了
应该怎么处理?
补充一下我看的书是Delphi2005入门与提高,使用的编译环境是Delphi2005 IDE(下载的).

解决方案 »

  1.   

    label1.text:= inputbox('输入提示'+'请输入问候名'+'world');
    这行中+号是不是改成逗号?
    我也是不熟,刚查的帮助
      

  2.   

    label1.Caption:= inputbox('输入提示','请输入问候名','world');
    第二个是对的,可能是你别的地方有错误。
      

  3.   

    大家说的都有道理,不过不是症结所在我把错误提示给大家,希望大家继续努力
    [Error] WinForm.pas(146): E2003 Undeclared identifier: 'showmessage'
    [Error] WinForm.pas(146): E2066 Missing operator or semicolon
    [Error] WinForm.pas(153): E2003 Undeclared identifier: 'inputbox'
    [Fatal Error] Project1.dpr(14): F2063 Could not compile used unit 'WinForm.pas'
      

  4.   

    原代码是:
    unit WinForm;interfaceuses
      System.Drawing, System.Collections, System.ComponentModel,
      System.Windows.Forms, System.Data;type
      TWinForm = class(System.Windows.Forms.Form)
      {$REGION 'Designer Managed Code'}
      strict private
        /// <summary>
        /// Required designer variable.
        /// </summary>
        Components: System.ComponentModel.Container;
        Label1: System.Windows.Forms.Label;
        Button1: System.Windows.Forms.Button;
        Button2: System.Windows.Forms.Button;
        Button3: System.Windows.Forms.Button;
        Button4: System.Windows.Forms.Button;
        ColorDialog1: System.Windows.Forms.ColorDialog;
        FontDialog1: System.Windows.Forms.FontDialog;
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        procedure InitializeComponent;
        procedure Button1_Click(sender: System.Object; e: System.EventArgs);
        procedure Button2_Click(sender: System.Object; e: System.EventArgs);
        procedure Button3_Click(sender: System.Object; e: System.EventArgs);
      {$ENDREGION}
      strict protected
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        procedure Dispose(Disposing: Boolean); override;
      private
        { Private Declarations }
      public
        constructor Create;
      end;  [assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]implementation{$AUTOBOX ON}{$REGION 'Windows Form Designer generated code'}
    /// <summary>
    /// Required method for Designer support -- do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    procedure TWinForm.InitializeComponent;
    begin
      Self.Label1 := System.Windows.Forms.Label.Create;
      Self.Button1 := System.Windows.Forms.Button.Create;
      Self.Button2 := System.Windows.Forms.Button.Create;
      Self.Button3 := System.Windows.Forms.Button.Create;
      Self.Button4 := System.Windows.Forms.Button.Create;
      Self.ColorDialog1 := System.Windows.Forms.ColorDialog.Create;
      Self.FontDialog1 := System.Windows.Forms.FontDialog.Create;
      Self.SuspendLayout;
      // 
      // Label1
      // 
      Self.Label1.Location := System.Drawing.Point.Create(64, 32);
      Self.Label1.Name := 'Label1';
      Self.Label1.Size := System.Drawing.Size.Create(192, 104);
      Self.Label1.TabIndex := 0;
      Self.Label1.Text := 'hello world!';
      // 
      // Button1
      // 
      Self.Button1.Location := System.Drawing.Point.Create(264, 24);
      Self.Button1.Name := 'Button1';
      Self.Button1.TabIndex := 1;
      Self.Button1.Text := 'hello';
      Include(Self.Button1.Click, Self.Button1_Click);
      // 
      // Button2
      // 
      Self.Button2.Location := System.Drawing.Point.Create(264, 56);
      Self.Button2.Name := 'Button2';
      Self.Button2.TabIndex := 2;
      Self.Button2.Text := 'color';
      Include(Self.Button2.Click, Self.Button2_Click);
      // 
      // Button3
      // 
      Self.Button3.Location := System.Drawing.Point.Create(264, 88);
      Self.Button3.Name := 'Button3';
      Self.Button3.TabIndex := 3;
      Self.Button3.Text := 'font';
      Include(Self.Button3.Click, Self.Button3_Click);
      // 
      // Button4
      // 
      Self.Button4.Location := System.Drawing.Point.Create(264, 120);
      Self.Button4.Name := 'Button4';
      Self.Button4.TabIndex := 4;
      Self.Button4.Text := '&quit';
      // 
      // TWinForm
      // 
      Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
      Self.ClientSize := System.Drawing.Size.Create(368, 189);
      Self.Controls.Add(Self.Button4);
      Self.Controls.Add(Self.Button3);
      Self.Controls.Add(Self.Button2);
      Self.Controls.Add(Self.Button1);
      Self.Controls.Add(Self.Label1);
      Self.Name := 'TWinForm';
      Self.Text := 'WinForm Demo';
      Self.ResumeLayout(False);
    end;
    {$ENDREGION}procedure TWinForm.Dispose(Disposing: Boolean);
    begin
      if Disposing then
      begin
        if Components <> nil then
          Components.Dispose();
      end;
      inherited Dispose(Disposing);
    end;constructor TWinForm.Create;
    begin
      inherited Create;
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent;
      //
      // TODO: Add any constructor code after InitializeComponent call
      //
    end;procedure TWinForm.Button3_Click(sender: System.Object; e: System.EventArgs);
    begin
      try
      fontdialog1.ShowDialog;
      label1.Font:=fontdialog1.Font;
      except
      showmessage('字体对话框显示失败。');
      end;
    end;procedure TWinForm.Button2_Click(sender: System.Object; e: System.EventArgs);
    begin
      try
      colordialog1.ShowDialog;
      label1.ForeColor:=colordialog1.Color;
      except
        showmessage('颜色对话框显示失败');  end;
    end;procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs);
    begin
      label1.text:='hello'+inputbox('输入提示','请输入问候名称:','world')+'!';
    end;end.
    希望大家多多努力帮我找到问题所在!
      

  5.   

    我用的delphi7这样写的,试验没问题
    Label1.Caption:= Inputbox('输入提示','请输入问候名','world');
    ShowMessage('颜色显示失败');
    你的错误提示是没有定义inputbox和ShowMessage函数
    你看看uses里面有没有加入Dialogs, StdCtrls
      

  6.   

    label1.text ×  应该label1.caption
    showmessage('颜色显示失败');出错?? 在uses 里 引用dialogs ;
      

  7.   

    最终解决方案是:
    uses里面加入Dialogs, StdCtrls
    label1.text不用该为label1.caption
    nevergetwin(头球冲顶)说的基本上是最好的