
'添加CommonDialog -- Nicrosoft Common Dualog Control 60
Dim excelPathName As String
Public Function DlgOpenFile(dlg As Object, filters As String) As String
With dlg
DialogTitle = "打开指定的文件"
Filter = "所有文件(" & filters & ")|" & filters
ShowOpen
DlgOpenFile = FileName
End With
End Function
Function lineRead(namePath As String) As String
'多行数据用这个
Dim strLine As String
Dim zzc As String
List1Clear
List2Clear
Open namePath For Input As #1
Do Until EOF(1)
Dim strs As Variant
Line Input #1, strLine
List1AddItem strLine
List2AddItem ""
Loop
Close #1
End Function
'全部提取
Private Sub Command1_Click()
Dim i As Integer
Dim n As Integer
Dim strs As Variant
n = List1ListCount
For i = 0 To n - 1
strs = Split(List1List(i), ",")
List2List(i) = strs(Text1 - 1)
Next
End Sub
'打开并读取
Private Sub Command2_Click()
excelPathName = DlgOpenFile(CommonDialog1, "txt")
Label1Caption = excelPathName
'在Label中显示路径,以供察看
lineRead excelPathName
End Sub
Private Sub Command3_Click()
List1Clear
End Sub
Private Sub Command4_Click()
List2Clear
End Sub
Private Sub List1_Click()
Dim strs As Variant
strs = Split(List1List(List1ListIndex), ",")
List2List(List1ListIndex) = strs(Text1 - 1)
End Sub
Private Sub Form_Load()
MeCaption = "张志晨VB助人程序V2011"
End Sub
问一句,你是调用还是直接嵌入?下面是直接嵌入的,你改改,这是我以前用到的
using System;
using SystemCollections;
using SystemComponentModel;
using SystemDrawing;
using SystemData;
using SystemWindowsForms;
using SystemRuntimeInteropServices;
namespace WinWordControl
{
public class DocumentInstanceException : Exception
{}
public class ValidDocumentException : Exception
{}
public class WordInstanceException : Exception
{}
public class WinWordControl : SystemWindowsFormsUserControl
{
[DllImport("user32dll")]
public static extern int FindWindow(string strclassName, string strWindowName);
[DllImport("user32dll")]
static extern int SetParent( int hWndChild, int hWndNewParent);
[DllImport("user32dll", EntryPoint="SetWindowPos")]
static extern bool SetWindowPos(
int hWnd, // handle to window
int hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
uint uFlags // window-positioning options
);
[DllImport("user32dll", EntryPoint="MoveWindow")]
static extern bool MoveWindow(
int爃Wnd,
int X,
int Y,
int爊Width,
int爊Height,
bool燽Repaint
);
const int SWP_DRAWFRAME = 0x20;
const int SWP_NOMOVE = 0x2;
const int SWP_NOSIZE = 0x1;
const int SWP_NOZORDER = 0x4;
private WordDocument document;
private static WordApplicationClass wd = null;
public static int wordWnd = 0;
private static string filename = null;
private static bool deactivateevents = false;
/// <summary>
/// needed designer variable
/// </summary>
private SystemComponentModelContainer components = null;
public WinWordControl()
{
InitializeComponent();
}
/// <summary>
/// cleanup Ressources
/// </summary>
protected override void Dispose( bool disposing )
{
CloseControl();
if( disposing )
{
if( components != null )
componentsDispose();
}
baseDispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// !do not alter this code! It's designer code
/// </summary>
private void InitializeComponent()
{
//
// WinWordControl
//
thisName = "WinWordControl";
thisSize = new SystemDrawingSize(440, 336);
thisResize += new SystemEventHandler(thisOnResize);
}
#endregion
/// <summary>
/// Preactivation
/// It's usefull, if you need more speed in the main Program
/// so you can preload Word
/// </summary>
public void PreActivate()
{
if(wd == null) wd = new WordApplicationClass();
}
/// <summary>
/// Close the current Document in the control --> you can
/// load a new one with LoadDocument
/// </summary>
public void CloseControl()
{
/
this code is to reopen Word
/
try
{
deactivateevents = true;
object dummy=null;
documentClose(ref dummy, ref dummy, ref dummy);
documentApplicationQuit(ref dummy, ref dummy, ref dummy);
deactivateevents = false;
}
catch
{
}
}
/// <summary>
/// catches Word's close event
/// starts a Thread that send a ESC to the word window ;)
/// </summary>
/// <param name="doc"></param>
/// <param name="test"></param>
private void OnClose(WordDocument doc, ref bool chancel)
{
if(!deactivateevents)
{
chancel=true;
}
}
/// <summary>
/// catches Word's open event
/// just close
/// </summary>
/// <param name="doc"></param>
private void OnOpenDoc(WordDocument doc)
{
OnNewDoc(doc);
}
/// <summary>
/// catches Word's newdocument event
/// just close
/// </summary>
/// <param name="doc"></param>
private void OnNewDoc(WordDocument doc)
{
if(!deactivateevents)
{
deactivateevents=true;
object dummy = null;
docClose(ref dummy,ref dummy,ref dummy);
deactivateevents=false;
}
}
/// <summary>
/// catches Word's quit event
/// normally it should not fire, but just to be shure
/// safely release the internal Word Instance
/// </summary>
private void OnQuit()
{
//wd=null;
}
统计DA_WORD数据区中正数、0、负数的个数,数据定义如下:
DA_WORD DW -1,3,5,0,-5,-7,4,0,-8……
COUNT EQU $-DA_WORD
NUM DB 0 ;存放正数的个数
DB 0 ;存放0的个数
DB 0 ;存放负数的个数
DATAS SEGMENT
ORG 1000H
DA_WORD DW 0FFFFH,3,5,0,0FFFBH,0FFF9H,4,0,0FFF8H
DOUNT EQU $-DA_WORD
ORG 1020H
NUM DB 0 ;存放正数的个数
ZE DB 0 ;存放0的个数
PLUS DB 0
DATAS ENDS
STACKS SEGMENT
DW 100 DUP(0)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
MOV AX,DOUNT
MOV CL,1
SHR AX,CL
MOV CX,AX
MOV SI,OFFSET DA_WORD
AG: MOV AX,[SI]
CMP AX,0
JNZ NOZ
INC [ZE]
JMP NEXT
NOZ:TEST AX,8000H
JNZ ISPLUS
INC [NUM]
JMP NEXT
ISPLUS:
INC [PLUS]
NEXT:
ADD SI,2
LOOP AG
INT 3
MOV AH,4CH
INT 21H
CODES ENDS
END START
以上就是关于如何用VB 把 文本文件里面任何一行 如:“43000,LD-Noz. offset.X,-200,pls” 里面的数字提取出来,假如要全部的内容,包括:如何用VB 把 文本文件里面任何一行 如:“43000,LD-Noz. offset.X,-200,pls” 里面的数字提取出来,假如要、c# 嵌入一个外部程序 如何让这个外部程序窗口最大化、试编制一个程序,统计DA_WORD数据区中正数、0、负数的个数等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)