word中vb 清除内容代码 vb清除文本框内容代码 - 电脑技术中心 - 【漳州电脑网】_漳州电脑维修_漳州笔记本电脑维修_监控安装_市区上门维修

全国统一24小时服务热线:400-0000-000400-0000-000  / 1399000000

当前位置:首页 > 电脑技术中心 > 正文

word中vb 清除内容代码 vb清除文本框内容代码

发布日期:2020-09-10

摘要:vb 只删除文件中的内容代码:using System; using System Collections Generic; using System Text; using System Runti...

word中vb 清除内容代码

vb 只删除文件中的内容

代码:using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace IniFiles { public abstract class CustomIniFile { public CustomIniFile(string AFileName) { FFileName = AFileName; } private string FFileName; public string FileName { get { return FFileName; } } public virtual bool SectionExists(string Section) { List vStrings = new List(); ReadSections(vStrings); return vStrings.Contains(Section); } public virtual bool ValueExists(string Section, string Ident) { List vStrings = new List(); ReadSection(Section, vStrings); return vStrings.Contains(Ident); } public abstract string ReadString(string Section, string Ident, string Default); public abstract bool WriteString(string Section, string Ident, string Value); public abstract bool ReadSectionValues(string Section, List Strings); public abstract bool ReadSection(string Section, List Strings); public abstract bool ReadSections(List Strings); public abstract bool EraseSection(string Section); public abstract bool DeleteKey(string Section, string Ident); public abstract bool UpdateFile(); } /// /// 存储本地INI文件的类。

/// public class IniFile : CustomIniFile { [DllImport("kernel32")] private static extern uint GetPrivateProfileString( string lpAppName, // points to section name string lpKeyName, // points to key name string lpDefault, // points to default string byte[] lpReturnedString, // points to destination buffer uint nSize, // size of destination buffer string lpFileName // points to initialization filename ); [DllImport("kernel32")] private static extern bool WritePrivateProfileString( string lpAppName, // pointer to section name string lpKeyName, // pointer to key name string lpString, // pointer to string to add string lpFileName // pointer to initialization filename ); /// /// 构造IniFile实例。

/// 指定文件名 /// public IniFile(string AFileName) : base(AFileName) { } /// /// 析够IniFile实例。

/// ~IniFile() { UpdateFile(); } /// /// 读取字符串值。

/// 指定变量标识。

/// 指定所在区域。

/// 指定默认值。

/// 返回读取的字符串。

如果读取失败则返回该值。

/// public override string ReadString(string Section, string Ident, string Default) { byte[] vBuffer = new byte[2048]; uint vCount = GetPrivateProfileString(Section, Ident, Default, vBuffer, (uint)vBuffer.Length, FileName); return Encoding.Default.GetString(vBuffer, 0, (int)vCount); } /// /// 写入字符串值。

/// /// 指定所在区域。

/// 指定变量标识。

/// 所要写入的变量值。

/// 返回写入是否成功。

public override bool WriteString(string Section, string Ident, string Value) { return WritePrivateProfileString(Section, Ident, Value, FileName); } /// /// 获得区域的完整文本。

(变量名=值格式)。

/// /// 指定区域标识。

/// 输出处理结果。

/// 返回读取是否成功。

public override bool ReadSectionValues(string Section, List Strings) { List vIdentList = new List(); if (!ReadSection(Section, vIdentList)) return false; foreach (string vIdent in vIdentList) Strings.Add(string.Format("{0}={1}", vIdent, ReadString(Section, vIdent, ""))); return true; } /// /// 读取区域变量名列表。

/// /// 指定区域名。

/// 指定输出列表。

/// 返回获取是否成功。

public override bool ReadSection(string Section, List Strings) { byte[] vBuffer = new byte[16384]; uint vLength = GetPrivateProfileString(Section, null, null, vBuffer, (uint)vBuffer.Length, FileName); int j = 0; for (int i = 0; i if (vBuffer[i] == 0) { Strings.Add(Encoding.Default.GetString(vBuffer, j, i - j)); j = i + 1; } return true; } /// /// 读取区域名列表。

/// /// 指定输出列表。

/// public override bool ReadSections(List Strings) { byte[] vBuffer = new byte[16384]; uint vLength = GetPrivateProfileString(null, null, null, vBuffer, (uint)vBuffer.Length, FileName); int j = 0; for (int i = 0; i if (vBuffer[i] == 0) { Strings.Add(Encoding.Default.GetString(vBuffer, j, i - j)); j = i + 1; } return true; } /// /// 删除指定区域。

/// /// 指定区域名。

/// 返回删除是否成功。

public override bool EraseSection(string Section) { return WritePrivateProfileString(Section, null, null, FileName); } /// /// 删除指定变量。

/// /// 变量所在区域。

/// 变量标识。

/// 返回删除是否成功。

public override bool DeleteKey(string Section, string Ident) { return WritePrivateProfileString(Section, Ident, null, FileName); } /// /// 更新文件。

/// /// 返回更新是否成功。

public override bool UpdateFile() { return WritePrivateProfileString(null, null, null, FileName); } } } EraseSection() // 删除一个区块 DeleteKey() // 删除一个键值

vb 6.0中删除一个文件代码怎么写

方法挺多,一楼滴,运用系统文件对象,楼上滴,VB自带函数Kill,我再介绍一种,调用CMD Shell "cmd /c del /f d:\jkd\jkl.exe",vbHide 各有各的优缺点,调用文件对象和Kill如果遇到有只读属性或系统属性的文件VB就会报错。

调用cmd的方法可以删除有只读属性或系统属性的文件,但需要有CMD的支持,如果系统没有CMD或CMD被锁定就没法使用。

vb中如何实数据(文本框中的内容)的清空

在桌面上单击鼠标右键,选择新建一个“记事本”,把下面红色部分复制进去,点“另存为”,把文件名定为“ 清除系统垃圾.bat ”就完成,记住后缀名一定要是.bat,然后把它移到一个您想要保存的目录,OK了!你的垃圾清除器就这样制作成功了!双击它就能很快地清理垃圾文件,大约一分钟不到。

@echo offecho 清除系统垃圾过程中,请稍等......del /f /s /q %systemdrive%\*.tmpdel /f /s /q %systemdrive%\*._mpdel /f /s /q %systemdrive%\*.logdel /f /s /q %systemdrive%\*.giddel /f /s /q %systemdrive%\*.chkdel /f /s /q %systemdrive%\*.olddel /f /s /q %systemdrive%\recycled\*.*del /f /s /q %windir%\*.bakdel /f /s /q %windir%\prefetch\*.*rd /s /q %windir%\temp & md %windir%\tempdel /f /q %userprofile%\cookies\*.*del /f /q %userprofile%\recent\*.*del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"del /f /s /q "%userprofile%\Local Settings\Temp\*.*"del /f /s /q "%userprofile%\recent\*.*"echo 清除系统垃圾完成!按任意键继续……echo. & pause 以后每隔一段时间你就可以双击些工具,运行完必就会还你一个“苗条”的系统了!!到时候再看看你的电脑,是不是急速如飞呢?这招比那些所谓的优化大师、超级兔子更加简便好用!不会破坏系统文件!

vb如何加一个清除文本框内容的按钮

Public StartPageNum As Integer, EndPageNum As Integer Sub aaa() Dim myDialog As FileDialog, oFile As Variant, oDoc As Document On Error Resume Next Set myDialog = Application.FileDialog(msoFileDialogFilePicker) myDialog.Filters.Clear "清除所有文件筛选器中的项目 myDialog.Filters.Add "所有 WORD 文件", "*.doc", 1 "增加筛选器的项目为所有WORD文件 myDialog.AllowMultiSelect = True "允许多项选择 If myDialog.Show -1 Then Exit Sub Dim SelectRange As Range DlgDelePage.Show vbModal If StartPageNum = 0 And EndPageNum = 0 Then Exit Sub End If For Each oFile In myDialog.SelectedItems "在所有选取项目中循环 Set oDoc = Documents.Open(FileName:=oFile, Visible:=True) "False) Dim Pages As Integer, StartPage As Long, EndPage As Long Pages = Selection.Information(wdNumberOfPagesInDocument) If Not (StartPageNum > Pages) Then If EndPageNum > Pages Then EndPageNum = Pages If StartPageNum = 1 Then StartPage = Selection.Range Else StartPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=StartPageNum - 1).Start End If If EndPageNum = Pages Then EndPage = ActiveDocument.Content.End Else EndPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=IIf(EndPageNum - StartPageNum > 0, EndPageNum - StartPageNum + 1, 1)).End ".Start End If ActiveDocument.Range(StartPage, EndPage).Select Selection.Delete End If "删除第3页批注 ActiveDocument.Words(1).Select "将光标移到文档开始位置 Dim myRange As Range, oComment As Comment Set myRange = Selection.Range StartPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=3 - 1).Start EndPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=3 - 1).End myRange = ActiveDocument.Range(StartPage, EndPage) If myRange.Comments.Count > 0 Then For Each oComment In myRange.Comments oComment.Delete Next End If oDoc.Save oDoc.Close Next oFile End Sub

上一篇:越狱后使用itools安装软件 itools不越狱安装软件

下一篇:word10行距 word表格内字体行距