vb.netref的简单介绍

如何用vb.net编程在cad图形中插入dwg图块?

Dim ppr As PromptPointResult = ed.GetPoint("请选择插入点:")

网站建设哪家好,找成都创新互联!专注于网页设计、网站建设、微信开发、小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了云梦免费建站欢迎大家使用!

Dim pt As Point3d = ppr.Value

utility.WriteToEditor(pt.ToString())

Dim pidBlock As New PIDBlock()

'自己定义的图块类,保存图块的路径和名称 

pidBlock.Name = "sample"

pidBlock.Path = blockPath  "b_sample.dwg"

Using blkDb As New Database(False, True)

'read drawing 

blkDb.ReadDwgFile(pidBlock.Path, System.IO.FileShare.Read, True, Nothing)

blkDb.CloseInput(True)

Using docLock As DocumentLock = doc.LockDocument()

'多文档要先这样,否则报至命错误 

Using t As Transaction = doc.TransactionManager.StartTransaction()

'insert it as a new block 

Dim idBTR As ObjectId = doc.Database.Insert(pidBlock.Name, blkDb, False)

'create a ref to the block 

Dim bt As BlockTable = DirectCast(t.GetObject(doc.Database.BlockTableId, OpenMode.ForRead), BlockTable)

Dim btr As BlockTableRecord = DirectCast(t.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)

Using bref As New BlockReference(pt, idBTR)

btr.AppendEntity(bref)

t.AddNewlyCreatedDBObject(bref, True)

End Using

t.Commit()

End Using

End Using

End Using

VB.NET RichTextBox 保存为 Word文档

将Word文档嵌入到WinForm窗体显示Word文档内容

private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)

{

OpenFileDialog P_GetFile = new OpenFileDialog();//创建打开文件对话框对象

DialogResult P_dr = P_GetFile.ShowDialog();//显示打开文件对话框

if (P_dr == DialogResult.OK)//是否点击确定

{

WebBrowser.Navigate(P_GetFile.FileName);//打开Word文档并显示

}

}

//在Word文档中插入图片

private void btn_New_Click(object sender, EventArgs e)

{

btn_New.Enabled = false;//停用新建按钮

ThreadPool.QueueUserWorkItem(//使用线程池

(P_temp) =//使用lambda表达式

{

G_wa = new Word.Application();//创建Word应用程序对象

Word.Document P_wd = G_wa.Documents.Add(//建立新文档

ref G_missing, ref G_missing, ref G_missing, ref G_missing);

Word.Range P_Range = P_wd.Paragraphs[1].Range;//得到段落范围

object P_Ranges = P_Range;//创建ojbect对象

P_wd.InlineShapes.AddPicture(//向文档中插入图片

G_OpenFileDialog.FileName, ref G_missing, ref G_missing, ref P_Ranges);

G_str_path = string.Format(//计算文件保存路径

@"{0}\{1}", G_FolderBrowserDialog.SelectedPath,

DateTime.Now.ToString("yyyy年M月d日h时s分m秒fff毫秒") + ".doc");

P_wd.SaveAs(//保存Word文件

ref G_str_path,

ref G_missing, ref G_missing, ref G_missing, ref G_missing,

ref G_missing, ref G_missing, ref G_missing, ref G_missing,

ref G_missing, ref G_missing, ref G_missing, ref G_missing,

ref G_missing, ref G_missing, ref G_missing);

((Word._Application)G_wa.Application).Quit(//退出应用程序

ref G_missing, ref G_missing, ref G_missing);

this.Invoke(//开始执行窗体线程

(MethodInvoker)(() =//使用lambda表达式

{

btn_Display.Enabled = true;//启用显示按钮

MessageBox.Show("成功创建Word文档!", "提示!");

}));

});

}

vb.net 如何引用C++ 的DLL中的某个函数?

(\"Data.dll\") Private Shared Function ConnectPlayServer(ByVal Address As String, ByVal Port As Integer, ByVal DataPort As Integer, ByVal Username As String) As Boolean

End Function

Private Declare Auto Function a Lib \"Lib.dll\" (ByVal i As Integer) As String

VB.net 如何实现记住密码 自动登录

代码如下:

/// summary

/// 连接到窗体:通过密码保护信息找回密码!

/// /summary

/// param name="sender"/param

/// param name="e"/param

private void lbl_mibao_Click(object sender, EventArgs e)

{

Getbackpwd getbackpwd = new Getbackpwd();

getbackpwd.Show();

}

/// summary

/// 当该窗体加载时从xml文件中读取用户信息并加载到combox的Items中

/// /summary

/// param name="sender"/param

/// param name="e"/param

private void Addresslist_Load(object sender, EventArgs e)

{

XmlTextReader reader = new XmlTextReader(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");

while (reader.Read())

{

//if (reader.LocalName.Equals("Name") || reader.LocalName.Equals("Number"))

if (reader.LocalName.Equals("username"))

{

this.cmbUserName.Items.Add(reader.ReadString());

}

//if (reader.LocalName.Equals("Number"))

//{

// this.label2.Text += reader.ReadString() + "\n";\

//}

}

reader.Close();

}

/// summary

/// 保存用户名到user.xml

/// /summary

//在listcontol上更改SelectedValue时执行从数据库读取密码的事件

private void cmbUserName_SelectedValueChanged(object sender, EventArgs e)

{

string username = cmbUserName.Text.Trim();

string sql = string.Format("select pwd from Admin where Username='{0}'", username);

try

{

SqlCommand command = new SqlCommand(sql, DBHelper.connection);

DBHelper.connection.Open();

SqlDataReader dataReader = command.ExecuteReader();

while (dataReader.Read())

{

txtpwd.Text = (string)dataReader["pwd"];

checkBoxpwd.Checked = true;

}

}

catch

{

MessageBox.Show("数据库操作出错!");

}

finally

{

DBHelper.connection.Close();

}

}

/// summary

/// 记住密码操作

/// /summary

/// param name="sender"/param

/// param name="e"/param

private void checkBoxpwd_Enter(object sender, EventArgs e)

{

bool check = true;

check = checkinput(cmbUserName.Text.Trim());

if ((string)cmbUserName.Text.Trim() == "")

{

MessageBox.Show("请输入用户名", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

cmbUserName.Focus();

}

else

{

if (txtpwd.Text.Trim() == "")

{

MessageBox.Show("请输入密码", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

txtpwd.Focus();

}

else

{

bool isValidUser = false; // 标识是否为合法用户

string message = ""; // 如果登录失败,显示的消息提示

// 如果验证通过,就显示相应的用户窗体,并将当前窗体设为不可见

if (ValidateInput())

{

// 调用用户验证方法

isValidUser = ValidateUser(cmbUserName.Text, txtpwd.Text, ref message);

// 如果是合法用户,显示相应的窗体

if (isValidUser)

{

if (check == true)

{

XmlDocument doc = new XmlDocument();

doc.Load(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");//(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");

XmlElement node = doc.CreateElement("user");

XmlNode xnode = (XmlNode)doc.CreateElement("username");

xnode.InnerText = cmbUserName.Text.Trim();

node.AppendChild(xnode);

doc.DocumentElement.InsertAfter(node, doc.DocumentElement.LastChild);

doc.Save(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");

//doc.Load (@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");

}

}

// 如果登录失败,显示相应的消息

else

{

MessageBox.Show(message, "记住密码失败!", MessageBoxButtons.OK, MessageBoxIcon.Information);

}

}

}

}

}

/// summary

/// 验证当前combox中内容是否已经存在于xml文件中

/// /summary

/// param name="text"/param

/// returns/returns

private bool checkinput(string text)

{

int count;

bool c = true;

for (count = 0; count cmbUserName.Items.Count;count ++ )

{

if (text ==(string )cmbUserName .Items [count])

{

c=false;

}

}

return c;

}

xml文件内容如下:?xml version="1.0" encoding="utf-8"?

person

user

VB.NET ReDim重定义动态数组

Array是一个类型,并非一个数组! 如果你想要传递数组,byval A() as string

VB.net 算术运算导致溢出

题主这个FunctionFindWindow(一堆参数)AsLong,返回值是个Long,而下面wd=FindWindow(),wd却是个Integer类型的,当然会溢出。楼上说都改成Long确实可以,不过题主的API声明是从VB里拷贝过来的吧?VB里的Long到.NET中就是Int32了,所以应该把上面FindWindow的返回类型由Long改为Int32(或者Integer)才是正解。


当前标题:vb.netref的简单介绍
文章URL:http://ybzwz.com/article/dodcdsd.html