在备忘录中不能将单词拼写成单个字母 [英] Cannot split word into individual letters in a memo

查看:157
本文介绍了在备忘录中不能将单词拼写成单个字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

unit frmDisplaySentence_u;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;

type
  TfrmDispOneChar = class(TForm)
    edtCode: TEdit;
    btnDisplay: TButton;
    lblMsg: TLabel;
    memOutput: TMemo;
    procedure btnDisplayClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmDispOneChar: TfrmDispOneChar;

implementation

{$R *.dfm}

procedure TfrmDispOneChar.btnDisplayClick(Sender: TObject);
var
    K, iLength : integer;
    cOne : char;
    sCode : string;
begin
    sCode := edtCode.Text;
    iLength := Length(sCode);
    for K := 1 to iLength do
        cOne := sCode[K];
        memOutput.Lines.Add(cOne);

end;






这是我的代码,将一个单词分割成备忘录中的单个字母,每个单独的行。


This is my code to split a word into it's individual letters in an memo, each in separate lines.

我的代码只返回单词的最后一个字母。我觉得这非常接近,但我不知道如何进一步。任何帮助将不胜感激。

My code only returns the last letter of the word. I feel this is very close but I do not know how to proceed further. Any help would be appreciated.

推荐答案

Delphi不像是Python,其中空格是重要的并定义块。在Delphi中,您必须使用 begin end 标记该块,在这种情况下为您的for循环:

Delphi is not like ie Python where whitespace is significant and defines block. In Delphi you have to use begin and end to mark the block, in this case your for loop:

procedure TfrmDispOneChar.btnDisplayClick(Sender: TObject);
var
    K, iLength : integer;
    cOne : char;
    sCode : string;
begin
    sCode := edtCode.Text;
    iLength := Length(sCode);
    for K := 1 to iLength do begin
        cOne := sCode[K];
        memOutput.Lines.Add(cOne);
    end;
end;

这篇关于在备忘录中不能将单词拼写成单个字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆