pascal文本 *** 作程序

pascal文本 *** 作程序,第1张

你是用的文本输入,这么可能读入值呀。。。

建个文本叫 ain;

然后207错误,也许是你的 s是整形,不能写成s/n;

s 必须是real 才行。。。

没编译你的程序,只是粗略的看了看,不知道上面说的对不对

使用MFC

//打开文件,并获取文本内容

CStdioFile file;

if(fileOpen(_T("Readmetxt"),CFile::modeRead))

{

CString sText = _T("");

CString strCont;

while( fileReadString(strCont) )

{

sText += strCont;

sText += _T("\r\n");

strCont=_T("");

}

fileClose();

//将文本的内容显示到Edit控件中。

//IDC_EDT_INFO,是Edit控件的ID

SetDlgItemText(IDC_EDT_INFO, sText);

}

插入文本就是把现有的Edit控件的文本作为一个字符串来处理就可以了。

CEdit的 *** 作,搜一下网上的内容吧。

using System;

using SystemCollectionsGeneric;

using SystemComponentModel;

using SystemData;

using SystemDrawing;

using SystemText;

using SystemIO;

using SystemWindowsForms;

namespace WindowsApplication2

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

/// <summary>

/// 当某个选项卡被取消选中时

/// </summary>

private void tabControl1_Deselected(object sender, TabControlEventArgs e)

{

eTabPageText = eTabPageTextTrimStart('');

}

/// <summary>

/// 当某个选项卡被选中时

/// </summary>

private void tabControl1_Selected(object sender, TabControlEventArgs e)

{

eTabPageText = "" + eTabPageText;

}

/// <summary>

/// 打开文件

/// </summary>

private void button1_Click(object sender, EventArgs e)

{

if (openFileDialog1ShowDialog() == DialogResultOK)

{

//取得当前的选项卡数目

int tabPageCount = thistabControl1TabPagesCount;

//取得欲打开的文件路径

string filePath = thisopenFileDialog1FileName;

//取得欲打开的文件名

string fileName = PathGetFileName(filePath);

//分析是否为txt格式的文件

if (PathGetExtension(filePath)ToLower() != "txt")

{

MessageBoxShow("非法文件格式!","打开文件失败",MessageBoxButtonsOK,MessageBoxIconStop);

return;

}

//采用"page"加上当前的选项卡数目加1做为选项卡的名称

string currentPageName = "page" + (tabPageCount + 1)ToString();

//采用"richTextBox"加上当前的选项卡数目加1做为选项卡中包含RichTextBox的名称

string currentTxtName = "richTextBox" + (tabPageCount + 1)ToString();

//添加一个新的选项卡,并指定其选项卡显示文字为当前打开的文件名

thistabControl1TabPagesAdd(currentPageName,fileName);

//实例化一个新的RichTextBox

RichTextBox ricTxt = new RichTextBox();

//设置其名称,布局等属性

ricTxtName = currentTxtName;

ricTxtDock = DockStyleFill;

//ricTxtTextChanged +=

//将新这个新的RichTextBox对象添加到当前新建的选项卡中

thistabControl1TabPages[currentPageName]ControlsAdd(ricTxt);

//将文件加载到当前的RichTextBox

ricTxtLoadFile(filePath,RichTextBoxStreamTypePlainText);

}

}

private void changePageText(string currentPageName)

{

thistabControl1TabPages[currentPageName]Text = "" + currentPageName;

}

}

}

namespace WindowsApplication2

{

partial class Form1

{

/// <summary>

/// 必需的设计器变量。

/// </summary>

private SystemComponentModelIContainer components = null;

/// <summary>

/// 清理所有正在使用的资源。

/// </summary>

/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

componentsDispose();

}

baseDispose(disposing);

}

#region Windows 窗体设计器生成的代码

/// <summary>

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。

/// </summary>

private void InitializeComponent()

{

thistabControl1 = new SystemWindowsFormsTabControl();

thisbutton1 = new SystemWindowsFormsButton();

thisopenFileDialog1 = new SystemWindowsFormsOpenFileDialog();

thisSuspendLayout();

//

// tabControl1

//

thistabControl1Location = new SystemDrawingPoint(0, -3);

thistabControl1Name = "tabControl1";

thistabControl1SelectedIndex = 0;

thistabControl1Size = new SystemDrawingSize(540, 510);

thistabControl1TabIndex = 0;

thistabControl1Selected += new SystemWindowsFormsTabControlEventHandler(thistabControl1_Selected);

thistabControl1Deselected += new SystemWindowsFormsTabControlEventHandler(thistabControl1_Deselected);

//

// button1

//

thisbutton1Location = new SystemDrawingPoint(22, 509);

thisbutton1Name = "button1";

thisbutton1Size = new SystemDrawingSize(75, 23);

thisbutton1TabIndex = 1;

thisbutton1Text = "浏览";

thisbutton1UseVisualStyleBackColor = true;

thisbutton1Click += new SystemEventHandler(thisbutton1_Click);

//

// openFileDialog1

//

thisopenFileDialog1FileName = "openFileDialog1";

//

// Form1

//

thisAutoScaleDimensions = new SystemDrawingSizeF(6F, 12F);

thisAutoScaleMode = SystemWindowsFormsAutoScaleModeFont;

thisClientSize = new SystemDrawingSize(539, 540);

thisControlsAdd(thisbutton1);

thisControlsAdd(thistabControl1);

thisName = "Form1";

thisText = "Form1";

thisResumeLayout(false);

}

#endregion

private SystemWindowsFormsTabControl tabControl1;

private SystemWindowsFormsButton button1;

private SystemWindowsFormsOpenFileDialog openFileDialog1;

}

}

可以做DOS批处理和脚本(vb 等)

批处理中只要输入DOS命令然后保存就可以

比如转换C盘到NTFS格式的命令 在文本文档中输入:

convert c: /fs:ntfs

然后保存为bat格式的文件就行了

1 打开记事本(Windows11系统自带),输入以下代码:

#include <stdioh>

int main()

{

printf("Hello World!\n");

return 0;

}

2 保存文件,例如:helloc

3 打开命令提示符(Windows11系统自带),输入以下命令:

gcc helloc -o hello

4 运行程序,输入以下命令:

/hello

以上就是关于pascal文本 *** 作程序全部的内容,包括:pascal文本 *** 作程序、用C++编一个英文文本处理程序,实现如下功能:1.显示文本的所有内容;2.在文本的开头或结尾插入一段文本、利用C#编写一段读写TXT文本的小程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/9291945.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-26
下一篇 2023-04-26

发表评论

登录后才能评论

评论列表(0条)

保存