快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

vb点虐 guan方示例的简单介绍

VB点虐 实例

1 生成txt文件。

成都创新互联从2013年创立,先为宝塔等服务建站,宝塔等地企业,进行企业商务咨询服务。为宝塔企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

DimSaveFileDialog1AsNewSaveFileDialog() '创建一个保存对话框

SaveFileDialog1.Filter ="txt files (*.txt)|*.txt" '设置扩展名

IfSaveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OKThen '如果确定保存

My.Computer.FileSystem.WriteAllText(SaveFileDialog1.Filename, Textbox1.Text,False) '保存文本,False表示不追加文本,直接覆盖其内容

EndIf

原文链接:

求高手给一个VB.NET的程序开机启动和关闭开机启动的示例代码

Private Sub 开机自动启动_Click(sender As Object, e As EventArgs) Handles 开机自动启动.Click

Dim a As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Run")

a.SetValue("查看.exe", Application.StartupPath "\查看.exe")

End Sub

Private Sub 关闭开机自启_Click(sender As Object, e As EventArgs) Handles 关闭开机自启.Click

Dim a As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Run")

a.DeleteValue("查看.exe")

End Sub

有没有人能详细的说明vb点虐 的特点,优缺点及应用领域?最好也举个运用VB.NET的例子啊!

Visual Basic .NET Visual Basic.NET是基于微软.NET Framework之上的面向对象的中间解释性语言,可以看作是Visual Basic在.Net Framework平台上的升级版本,增强了对面向对象的支持。但由于改动太大,导致VB点虐 对VB的向后兼容性不好,在业界引起不小的争议。 大多的VB.Net程序员使用Visual Studio .Net作为IDE(integrated development environment). SharpDevelop是另一种可用的开源的IDE。VB.Net需要在.Net Framework平台上才能执行。 VB.NET的主页 1 目前版本 2005年9月以来,存在三种不同版本的Visual Basic .NET. 1 Visual Basic .NET:是随vc#和ASP.NET一起在2002年发布的最初始的VB点虐 版本。C#被大力宣传为微软对付JAVA的王牌,受到媒体极力关注。然而VB.NET(有时被称为VB7)影响面不广,这导致VB社区之外很少人关注它。那些试用过此版VB.NET的人在层层幕布下发现一个强大却艰深的语言,而且还有不少弱点,比如它比VB6来有一个大了十倍的进行时(RunTime),内存footprint也大大增加。 2 Visual Basic .NET 2003:是和.NET Framework 1.1一起发布的。新功能包括对.NET Compact Framework的支持和更好的VB升迁向导。并改进了运行状况,IDE稳定性(尤其是后台编译器),以及运行时RunTime稳定性。另外,VB.NET 2003还有一个学院版Visual Studio .NET 2003 Academic Edition (VS03AE),它是分发给各国某些学者免费使用的版本。 3 Visual Basic 2005:VB2005是VB.Net的重大转变,微软决意在其软件名称中去掉了.NET部份。在VB2005中,微软增加了许多新功能,以引用VB对于初学者来说的一些优点: A, Edit and Continue - 也许是从VB那里丢掉的最大的功能,允许代码的编辑和执行立即的执行恢复。 B, Design-time expression evaluation C, My伪命名空间,提供了访问.NET Framework特定域的不需大量编码的简单方式;还能动态产生类(显然的是My.Forms);提供了改进的VB到VB.NET转换向导;Using 语法,简化了需要部署pattern to free resources的对象的使用;My编码,可隐藏由VB.NET IDE写的模板代码;数据源绑定,简化了数据库C/S开发 上述功能(尤其是My)增强了VB.Net成为快速开发应用平台的可能,并与C#进一步区别开来。参见: 使用My开发 通过My命名空间访问.NET Framework 和项目 Visual Basic 2005 通过增加新功能而填补了和其它所谓更强大的.NET语言的差距。 A, 增加了.NET 2.0语言功能包括:generics和Partial类(在一个文件里定义一个类的某部份然后再添加更多的定义,这个方法在整合用户编码和系统自动生成编码时尤其有用)。 B, XML注释,可以被NDoc等工具处理而自动生成文档 C, operator overloading D, 支持在其它语言中已经广泛使用的unsigned integer数据类型。 E, 支持在许多C衍生编程语言已提供的复合操作符如:"+=", "-=" 4, IsNot专利:If Not X Is Y表达式被转换成If X IsNot Y。当微软为IsNot申请专利时招致了恶名(尤其来自Real公司)。 5, Visual Basic 2005 Express:作为VS产品线上的一部份,VB2005 Express是专为业余爱好者和新手定制的免费的VS Express系列的一员。Express版本目的定位在帮助人们学习一种语言,所以他们有和标准版一致的用户界面,只是少了一些高级功能。另外,VS 查看更多答案

记得采纳啊

vb点虐 中如何用事件和委托,会C#中的事件和委托,但不知VB点虐 中的语法,望给个简单的例子熟悉语法。

一委托:此示例演示如何将方法与委托关联然后通过委托调用该方法。

创建委托和匹配过程

创建一个名为 MySubDelegate 的委托。

Delegate Sub MySubDelegate(ByVal x As Integer)

声明一个类,该类包含与该委托具有相同签名的方法。

Class class1

Sub Sub1(ByVal x As Integer)

MsgBox("The value of x is: " CStr(x))

End Sub

End Class

定义一个方法,该方法创建该委托的实例并通过调用内置的 Invoke 方法调用与该委托关联的方法。

Protected Sub DelegateTest()

Dim c1 As New class1

' Create an instance of the delegate.

Dim msd As MySubDelegate = AddressOf c1.Sub1

' Call the method.

msd.Invoke(10)

End Sub

二、事件

下面的示例程序阐释如何在一个类中引发一个事件,然后在另一个类中处理该事件。AlarmClock 类定义公共事件 Alarm,并提供引发该事件的方法。AlarmEventArgs 类派生自 EventArgs,并定义 Alarm 事件特定的数据。WakeMeUp 类定义处理 Alarm 事件的 AlarmRang 方法。AlarmDriver 类一起使用类,将使用 WakeMeUp 的 AlarmRang 方法设置为处理 AlarmClock 的 Alarm 事件。

该示例程序使用事件和委托和引发事件中详细说明的概念。

示例

' EventSample.vb.

'

Option Explicit

Option Strict

Imports System

Imports System.ComponentModel

Imports Microsoft.VisualBasic

Namespace EventSample

' Class that contains the data for

' the alarm event. Derives from System.EventArgs.

'

Public Class AlarmEventArgs

Inherits EventArgs

Private _snoozePressed As Boolean

Private nrings As Integer

'Constructor.

'

Public Sub New(snoozePressed As Boolean, nrings As Integer)

Me._snoozePressed = snoozePressed

Me.nrings = nrings

End Sub

' The NumRings property returns the number of rings

' that the alarm clock has sounded when the alarm event

' is generated.

'

Public ReadOnly Property NumRings() As Integer

Get

Return nrings

End Get

End Property

' The SnoozePressed property indicates whether the snooze

' button is pressed on the alarm when the alarm event is generated.

'

Public ReadOnly Property SnoozePressed() As Boolean

Get

Return _snoozePressed

End Get

End Property

' The AlarmText property that contains the wake-up message.

'

Public ReadOnly Property AlarmText() As String

Get

If _snoozePressed Then

Return "Wake Up!!! Snooze time is over."

Else

Return "Wake Up!"

End If

End Get

End Property

End Class

' Delegate declaration.

'

Public Delegate Sub AlarmEventHandler(sender As Object, _

e As AlarmEventArgs)

' The Alarm class that raises the alarm event.

'

Public Class AlarmClock

Private _snoozePressed As Boolean = False

Private nrings As Integer = 0

Private stopFlag As Boolean = False

' The Stop property indicates whether the

' alarm should be turned off.

'

Public Property [Stop]() As Boolean

Get

Return stopFlag

End Get

Set

stopFlag = value

End Set

End Property

' The SnoozePressed property indicates whether the snooze

' button is pressed on the alarm when the alarm event is generated.

'

Public Property SnoozePressed() As Boolean

Get

Return _snoozePressed

End Get

Set

_snoozePressed = value

End Set

End Property

' The event member that is of type AlarmEventHandler.

'

Public Event Alarm As AlarmEventHandler

' The protected OnAlarm method raises the event by invoking

' the delegates. The sender is always this, the current instance

' of the class.

'

Protected Overridable Sub OnAlarm(e As AlarmEventArgs)

RaiseEvent Alarm(Me, e)

End Sub

' This alarm clock does not have

' a user interface.

' To simulate the alarm mechanism it has a loop

' that raises the alarm event at every iteration

' with a time delay of 300 milliseconds,

' if snooze is not pressed. If snooze is pressed,

' the time delay is 1000 milliseconds.

'

Public Sub Start()

Do

nrings += 1

If stopFlag Then

Exit Do

Else

If _snoozePressed Then

System.Threading.Thread.Sleep(1000)

If (True) Then

Dim e As New AlarmEventArgs(_snoozePressed, nrings)

OnAlarm(e)

End If

Else

System.Threading.Thread.Sleep(300)

Dim e As New AlarmEventArgs(_snoozePressed, nrings)

OnAlarm(e)

End If

End If

Loop

End Sub

End Class

' The WakeMeUp class has a method AlarmRang that handles the

' alarm event.

'

Public Class WakeMeUp

Public Sub AlarmRang(sender As Object, e As AlarmEventArgs)

Console.WriteLine((e.AlarmText + ControlChars.Cr))

If Not e.SnoozePressed Then

If e.NumRings Mod 10 = 0 Then

Console.WriteLine(" Let alarm ring? Enter Y")

Console.WriteLine(" Press Snooze? Enter N")

Console.WriteLine(" Stop Alarm? Enter Q")

Dim input As String = Console.ReadLine()

If input.Equals("Y") Or input.Equals("y") Then

Return

Else

If input.Equals("N") Or input.Equals("n") Then

CType(sender, AlarmClock).SnoozePressed = True

Return

Else

CType(sender, AlarmClock).Stop = True

Return

End If

End If

End If

Else

Console.WriteLine(" Let alarm ring? Enter Y")

Console.WriteLine(" Stop Alarm? Enter Q")

Dim input As String = Console.ReadLine()

If input.Equals("Y") Or input.Equals("y") Then

Return

Else

CType(sender, AlarmClock).Stop = True

Return

End If

End If

End Sub

End Class

' The driver class that hooks up the event handling method of

' WakeMeUp to the alarm event of an Alarm object using a delegate.

' In a forms-based application, the driver class is the

' form.

'

Public Class AlarmDriver

Public Shared Sub Main()

' Instantiates the event receiver.

Dim w As New WakeMeUp()

' Instantiates the event source.

Dim clock As New AlarmClock()

' Wires the AlarmRang method to the Alarm event.

AddHandler clock.Alarm, AddressOf w.AlarmRang

clock.Start()

End Sub

End Class

End Namespace


网页标题:vb点虐 guan方示例的简单介绍
路径分享:http://6mz.cn/article/ddesejs.html

其他资讯