189 8069 5689

vb.netsip的简单介绍

vb. net是面向对象的编程语言是对吗?

VB.net

成都创新互联公司主要从事网站制作、网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务会昌,10余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792

相对VB出现巨大变化的是语意,从运行于基于COM的deterministic,

reference-counted的引擎之上的编程环境,转变为全面面向对象的基于.NET

Framework的语言。.NET

Framework包括了CLR(使用通用垃圾收集机制和JIT编译引擎的虚拟机)和大量的类库。VB开发者进入VB.NET要面对新增的大量类库的问题。

上述变化表明了许多在运行及维护相关优化事宜下面的假定,一些VB6函数和库不再存在而其它的仍然可用,但是比不上.NET语言中自带的可替换的函数和库来得高效。即使它们可被编译,但大多从VB6转换而来的应用将需要一定程度上的重构(refactoring),以全面利用新语言的优点。在有关句法、应用调试、部署和术语等方面的变化,有大量的文档可以参考。

vb.net编写程序时如何存储设置参数?

比较专业的做法是在项目中添加微软的Application Settings类,详细帮助文档:

使用极其简单,假设在settings1.settings设置一个项目,名称:IP,类型:String,范围:用户,值:192.168.1.1

调用:Dim sIP As String = setting.IP

获取缺省值:Dim sIP As String = Settings1.Default.IP

保存: setting.IP = "192.168.1.30" : setting.Save()

用vb.net实现网络通信

用 vb.net socket通信

Dim th As Threading.Thread

2 Dim tcpl As System.Net.Sockets.TcpListener

3

4 Private Sub Form1_Load()Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

5 th = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf MyListen))

6 th.Start()

7 End Sub

8

9 Public Sub SendMessage()Sub SendMessage(ByVal IP As String, ByVal SendMsg As String)

10 Try

11 If IP "" Then

12 Dim tcpc As New System.Net.Sockets.TcpClient(IP, 5656)

13 Dim tcpStream As Net.Sockets.NetworkStream = tcpc.GetStream

14 Dim reqStream As New IO.StreamWriter(tcpStream)

15 reqStream.Write(SendMsg)

16 reqStream.Flush()

17 tcpStream.Close()

18 tcpc.Close()

19 End If

20 Catch ex As Exception

21 MsgBox(ex.Message.ToString)

22 End Try

23 End Sub

24 Private Sub MyListen()Sub MyListen()

25 Try

26 Dim ipAddress As System.Net.IPAddress = System.Net.Dns.Resolve(System.Net.Dns.GetHostName).AddressList(0)

27 tcpl = New System.Net.Sockets.TcpListener(ipAddress, 5656)

28 tcpl.Start()

29 While True

30 Dim s As System.Net.Sockets.Socket = tcpl.AcceptSocket()

31 Dim MyBuffer(1024) As Byte

32 Dim i As Integer

33 i = s.Receive(MyBuffer)

34 If i 0 Then

35 Dim lstrRec As String

36 Dim j As Integer

37 For j = 0 To i - 1

38 TextBox1.Text += Chr(MyBuffer(j)) ","

39 Next

40 End If

41 End While

42 Catch ex As Exception

43 MsgBox(ex.Message.ToString)

44 End Try

45 End Sub

46

47 Private Sub Button1_Click()Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

48 SendMessage("192.168.0.61", TextBox2.Text)

49 End Sub

vb.net 获取局域网计算机的当前用户名和计算机型号等信息

Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Sub GetName()

Dim sJM As String

Dim sMC As String

Dim sIP As String

Dim s As String

s = String(128, Chr(0))

GetComputerName s, Len(s)

s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))

sJM = s'计算机名称

s = String(128, Chr(0))

GetUserName s, Len(s)

s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))

sMC = s‘当前用户名称

End Sub

'用这种方法在远程获得再发回本机就可以吧

'取计算机型号暂时不会


本文名称:vb.netsip的简单介绍
浏览路径:http://cdxtjz.cn/article/hceghd.html

其他资讯