vb点虐 组件开发 vbnet ide
vb点虐 的COM组件的编写问题
我想了两种思路,winform没有findControl,只有个this.Controls.Contains("textBox1"),因此除了遍历没办法了。。。
创新互联公司主要为客户提供服务项目涵盖了网页视觉设计、VI标志设计、营销网站、网站程序开发、HTML5响应式成都网站建设、成都做手机网站、微商城、网站托管及网站维护公司、WEB系统开发、域名注册、国内外服务器租用、视频、平面设计、SEO优化排名。设计、前端、后端三个建站步骤的完善服务体系。一人跟踪测试的建站服务标准。已经为成都宣传片制作行业客户提供了网站推广服务。
思路1:遍历Controls,具体你自己完善下,
if(this.Controls.Count0)
{
foreach(Control c in this.Controls)
if(c.GetTepy==Tepyof(TextBox))
string str += ((TextBox)c).Text;
}
VB.NET中的组件开发
简介 组件其实是一段可以重用的代码 通过遵循IComponent接口的标准来实现一个组件 所以有组件都是派生于Component类 由Component类来实现IComponent接口 在组件中应正确使用函数的访问级别来控制外部对其的访问限制 只要有足够的权限就可以将组件放到自己的程序中而不用担心组件会产生多大的错误 因为组件已经经过测试的 比如说可以把一段登录的程序做成一个组件 或者把经常使用到的一些功能也做成组件 这样就可以减少开发中的错误 也可以缩短开发时间 组件之间也可以互相套用 如一个组件引用另一个组件 都是没问题 但要先在Add Reference中添加对组件的引用 在 NET中是通过把组件放在程序集中来实现的 程序集中存放著这些组件所依赖的文件信息和所在路径 因此CLR就可以通过这些信息来确定组件所需要的其他程序集的位置 ( 另外在组件设计过程中应好好利用接口来设计组件) 在VS中创建组件 选建一个Project 再从模板中选Class Library OK 接着再从Project菜单中Add Component 到些为止 组件的一个框架就呈现在眼前 平台自动继承了Component类和构造函数 可以删除原先创建类库时自动生成的Class 看应用的需要 接着就可以在组件类里写要实现的功能 最后从Build(生成)菜单中选择Build Solution(生成解决方案)来生成组件 如果生成成功的话 到应用程序的BIN目录下会看到一个DLL文件 引用组件 只要在Solution Explorer窗口中 添加对DLL的Reference就可以了 Imports loginValidator Imports System Data Imports System Data SqlClient Public Class loginFormClass loginForm Inherits System Windows Forms Form #Region Windows 窗体设计器生成的代码 Public Sub New()Sub New() MyBase New() 该调用是 Windows 窗体设计器所必需的 InitializeComponent() 在 InitializeComponent() 调用之后添加任何初始化 End Sub 窗体重写 dispose 以清理组件列表 Protected Overloads Overrides Sub Dispose()Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (ponents Is Nothing) Then ponents Dispose() End If End If MyBase Dispose(disposing) End Sub Windows 窗体设计器所必需的 Private ponents As System ComponentModel IContainer 注意: 以下过程是 Windows 窗体设计器所必需的 可以使用 Windows 窗体设计器修改此过程 不要使用代码编辑器修改它 Friend WithEvents lblUserPwd As System Windows Forms Label Friend WithEvents lblUserName As System Windows Forms Label Friend WithEvents txtUserName As System Windows Forms TextBox Friend WithEvents txtUserPwd As System Windows Forms TextBox Friend WithEvents btnSubmit As System Windows Forms Button Friend WithEvents btnExit As System Windows Forms Button Friend WithEvents Label As System Windows Forms Label Friend WithEvents Label As System Windows Forms Label Friend WithEvents btnCancel As System Windows Forms Button Friend WithEvents Label As System Windows Forms Label System Diagnostics DebuggerStepThrough() Private Sub InitializeComponent()Sub InitializeComponent() Dim resources As System Resources ResourceManager = New System Resources ResourceManager(GetType(loginForm)) Me lblUserPwd = New System Windows Forms Label Me lblUserName = New System Windows Forms Label Me txtUserName = New System Windows Forms TextBox Me txtUserPwd = New System Windows Forms TextBox Me btnSubmit = New System Windows Forms Button Me btnExit = New System Windows Forms Button Me Label = New System Windows Forms Label Me Label = New System Windows Forms Label Me btnCancel = New System Windows Forms Button Me Label = New System Windows Forms Label Me SuspendLayout() lblUserPwd Me lblUserPwd Location = New System Drawing Point( ) Me lblUserPwd Name = lblUserPwd Me lblUserPwd Size = New System Drawing Size( ) Me lblUserPwd TabIndex = Me lblUserPwd Text = 密码 Me lblUserPwd TextAlign = System Drawing ContentAlignment MiddleCenter lblUserName Me lblUserName Location = New System Drawing Point( ) Me lblUserName Name = lblUserName Me lblUserName Size = New System Drawing Size( ) Me lblUserName TabIndex = Me lblUserName Text = 帐号 Me lblUserName TextAlign = System Drawing ContentAlignment MiddleCenter txtUserName Me txtUserName BackColor = System Drawing SystemColors Info Me txtUserName BorderStyle = System Windows Forms BorderStyle FixedSingle Me txtUserName Location = New System Drawing Point( ) Me txtUserName Name = txtUserName Me txtUserName Size = New System Drawing Size( ) Me txtUserName TabIndex = Me txtUserName Text = txtUserPwd Me txtUserPwd BackColor = System Drawing SystemColors Info Me txtUserPwd BorderStyle = System Windows Forms BorderStyle FixedSingle Me txtUserPwd Location = New System Drawing Point( ) Me txtUserPwd Name = txtUserPwd Me txtUserPwd PasswordChar = Microsoft VisualBasic ChrW( ) Me txtUserPwd Size = New System Drawing Size( ) Me txtUserPwd TabIndex = Me txtUserPwd Text = btnSubmit Me btnSubmit BackColor = System Drawing SystemColors ActiveBorder Me btnSubmit Cursor = System Windows Forms Cursors Hand Me btnSubmit ForeColor = System Drawing SystemColors InfoText Me btnSubmit Location = New System Drawing Point( ) Me btnSubmit Name = btnSubmit Me btnSubmit TabIndex = Me btnSubmit Text = 登录 btnExit Me btnExit BackColor = System Drawing SystemColors ActiveBorder Me btnExit Cursor = System Windows Forms Cursors Hand Me btnExit Location = New System Drawing Point( ) Me btnExit Name = btnExit Me btnExit TabIndex = Me btnExit Text = 退出 Label Me Label Font = New System Drawing Font( Impact ! System Drawing FontStyle Regular System Drawing GraphicsUnit Point CType( Byte)) Me Label Location = New System Drawing Point( ) Me Label Name = Label Me Label Size = New System Drawing Size( ) Me Label TabIndex = Me Label Text = TEST Label Me Label BackColor = System Drawing SystemColors ControlText Me Label ForeColor = System Drawing SystemColors HighlightText Me Label Location = New System Drawing Point( ) Me Label Name = Label Me Label Size = New System Drawing Size( ) Me Label TabIndex = Me Label Text = 系统登录 Me Label TextAlign = System Drawing ContentAlignment MiddleCenter btnCancel Me btnCancel BackColor = System Drawing SystemColors ActiveBorder Me btnCancel Cursor = System Windows Forms Cursors Hand Me btnCancel Location = New System Drawing Point( ) Me btnCancel Name = btnCancel Me btnCancel TabIndex = Me btnCancel Text = 取消 Label Me Label ForeColor = System Drawing Color Red Me Label Location = New System Drawing Point( ) Me Label Name = Label Me Label Size = New System Drawing Size( ) Me Label TabIndex = Me Label Text = 为保证系统安全 请先登录 loginForm Me AutoScaleBaseSize = New System Drawing Size( ) Me BackColor = System Drawing SystemColors ActiveBorder Me ClientSize = New System Drawing Size( ) Me Controls Add(Me Label ) Me Controls Add(Me btnCancel) Me Controls Add(Me Label ) Me Controls Add(Me Label ) Me Controls Add(Me btnExit) Me Controls Add(Me txtUserPwd) Me Controls Add(Me txtUserName) Me Controls Add(Me btnSubmit) Me Controls Add(Me lblUserName) Me Controls Add(Me lblUserPwd) Me FormBorderStyle = System Windows Forms FormBorderStyle None Me Icon = CType(resources GetObject( $this Icon ) System Drawing Icon) Me MaximizeBox = False Me MinimizeBox = False Me Name = loginForm Me SizeGripStyle = System Windows Forms SizeGripStyle Hide Me StartPosition = System Windows Forms FormStartPosition CenterScreen Me Tag = 登录 Me Text = TEST 系统登录 Me ResumeLayout(False) End Sub #End Region Private Sub loginForm_Load()Sub loginForm_Load(ByVal sender As System Object ByVal e As System EventArgs) Handles MyBase Load txtUserName Focus() btnCancel Visible = False End Sub Private Sub btnExit_Click()Sub btnExit_Click(ByVal sender As System Object ByVal e As System EventArgs) Handles btnExit Click Application Exit() End Sub Private Sub btnSubmit_Click()Sub btnSubmit_Click(ByVal sender As System Object ByVal e As System EventArgs) Handles btnSubmit Click 调用loginValidator组件 Dim validator As New Validator validator vUsername = txtUserName Text Trim validator vUserpwd = txtUserPwd Text Trim If (validator validate() = True) Then Me Close() Else MessageBox Show( 帐号或密码错误 请重试! 验证错误 MessageBoxButtons OK MessageBoxIcon Warning) End If End Sub Private Sub btnCancel_Click()Sub btnCancel_Click(ByVal sender As System Object ByVal e As System EventArgs) Me Dispose() End Sub Private Sub btnCancel_Click_ ()Sub btnCancel_Click_ (ByVal sender As System Object ByVal e As System EventArgs) Handles btnCancel Click Me Close() End Sub End Class 关于在 NET中使用组件 NET可以向后兼容 并支持了和ActiveX对象等早期版本的应用程序 在 NET中使用等很有趣 NET创建一个包将它们包装起来 而它们之间的交互就是通过这个包装来进行的 这个包就叫做运行时可呼叫包装(RCW) 可以直接使用 也可以先转换成 NET程序集后再使用 直接使用组件是通过Add Reference来实现的 这种方法通过RCW来包装 缺点 无法放到 GAC中 不能重用 通过转换成 NET程序集来使用 是通过利用 tlbimp 命令行工具来实现的 语法 tlbimp Name dll /out:Comp dll /namespace:myNS /a *** Version: myVersion /reference:refname 第一个为的名称 第二个为要生成的 NET组件名称 第三个为要生成的名称空间 第四个为 版本号 第四个指定引用的文件名 lishixinzhi/Article/program/net/201311/12392
用VB.NET编程有什么好处?
vb点虐 是基于.NET框架的完全对向对象的编程语言,而vb 6.0只是半面向对象的语言,使用vb点虐 可以编制出功能更加强大的windows程序。现在,我们把vb点虐 和vb 6.0做一下比较,看看vb点虐 对比vb 6.0有着什么样的特性和优点。 1.在vb 6.0中,创建对象的时候,需要等这个对象创建完毕后,再另外调用一个独立的方法对其进行初始化。在vb点虐 中, 可以利用构造函数为对象赋初值,这样就不需要进行烦琐的调用赋初值了。构造函数的使用,简化了编码的过程和出错的机会。 2.vb点虐 编写线程的能力比vb 6.0有很大的增强。 3.在vb 6.0中,需要首先声明一个变量,然后才能对其赋值,这样就需要写两行代码。在vb点虐 中,可以 使用初始化函数将这两个步骤合并在一行代码中完成,这个似乎微小的改进,提供了更少、更简单、更易于维护的代码。 4.vb点虐 基于.NET框架,开发者可以快速的可视化开发网络应用程序、网络服务、Windows应用程序和服务器端组件。 5.因为vb点虐 是基于.NET框架的,可以与其它.NET语言协同工作。 6.在vb点虐 中,通过Web窗体及ADO.NET,开发者可以快速开发可扩展的Web站点。 如果你能进一步学习vb点虐 ,你会发现更多的新特性和优点。
网站标题:vb点虐 组件开发 vbnet ide
文章出自:http://azwzsj.com/article/ddjhise.html