VB2010從入門到精通

上傳人:zh****u6 文檔編號:34807548 上傳時間:2021-10-23 格式:DOCX 頁數(shù):167 大?。?.06MB
收藏 版權申訴 舉報 下載
VB2010從入門到精通_第1頁
第1頁 / 共167頁
VB2010從入門到精通_第2頁
第2頁 / 共167頁
VB2010從入門到精通_第3頁
第3頁 / 共167頁

下載文檔到電腦,查找使用更方便

30 積分

下載資源

還剩頁未讀,繼續(xù)閱讀

資源描述:

《VB2010從入門到精通》由會員分享,可在線閱讀,更多相關《VB2010從入門到精通(167頁珍藏版)》請在裝配圖網(wǎng)上搜索。

1、很多事情失敗的原因不是行動前沒有計劃, 而是缺少計劃前的行動。 注意力在結果上 不做準備就是準備失敗 開大會時說大話,開小會時說小話 時間可以換取空間,空間可以換取時間 當動則動,當止則止 民主很重要,但群體是不能做決策的 將在外君令有所不受,但一定要付出代價。自己應懂得承受,但人才是不會被埋沒的。 人,是留不住的,即使你能把他留住在身邊,也不能把他留住在人世。但能留住的是什么?(孔子去了,儒家思想?yún)s仍生生不息;牛頓走了,可三大定律依舊在為人類造福;愛迪生也走了,可夜晚再不僅是一片漆黑;) 領導力是獲得追隨者的能力 領導者的價值在于把追隨者變?yōu)轭I導者。 勇于敢則殺,勇于

2、不敢則活(勇敢可以殺敵,但是懂得隱蔽才能保存自己,好的戰(zhàn)士是既會沖鋒又會隱蔽的) 用人所長必容人所短 人生很大的誤區(qū)在于見到好友不交,見到名師不敗。 一個境界低的人講不出來高遠的話,一個沒有使命感的人講不出來有責任的話,一個格局小的人,講不出來大氣的話。 凡是能干大事的人都是能夠坐得住的人。 如果沒有這么多人干擾我,哪有我做球星的價值。--------馬拉多納 不怕念起,就怕覺遲。 VB2010 知識寶庫 VB.NET常用命名空間和類介紹 一、基礎命名空間 System.Collections 包含了一些與集合相關的類型,比如列表,隊列,位數(shù)組,哈希表和字典等. (數(shù)

3、據(jù)結構) System.IO 包含了一些數(shù)據(jù)流類型并提供了文件和目錄同步異步讀寫. System.Text 包含了一些表示字符編碼的類型并提供了字符串的操作和格式化 System.Reflection 包括了一些提供加載類型,方法和字段的托管視圖以及動態(tài)創(chuàng)建和調用類型功能的類型. System.Threading 提供啟用多線程的類和接口 二、圖形命名空間 System.Drawing 這個主要的GDI+命名空間定義了許多類型,實現(xiàn)基本的繪圖類型(字體,鋼筆,基本畫筆等)和無所不能的Graphics對象. System.Drawing2D 這個命名空間提供高級的二維和

4、失量圖像功能. System.Drawing.Imaging 這個命名空間定義了一些類型實現(xiàn)圖形圖像的操作. System.Drawing.Text 這個命名空間提供了操作字體集合的功能. System.Drawing.Printing 這個命名空間定義了一些類型實現(xiàn)在打印紙上繪制圖像,和打印機交互以及格式化某個打印任務的總體外觀等功能. 三、數(shù)據(jù)命名空間 System.Data 包含了數(shù)據(jù)訪問使用的一些主要類型. System.Data.Common 包含了各種數(shù)據(jù)庫訪問共享的一些類型. System.XML 包含了根據(jù)標準來支持XML處理的類. System

5、.Data.OleDb 包含了一些操作OLEDB數(shù)據(jù)源的類型 . System.Data.Sql 能使你枚舉安裝在當前本地網(wǎng)絡的SQLServer實例. System.Data.SqlClient 包含了一些操作MSSQLServer數(shù)據(jù)庫的類型,提供了和System.Data.OleDb相似的功能,但是針對SQL做了優(yōu)化.(優(yōu)化后的SQL操作類庫) System.Data.SqlTypes 提供了一些表示SQL數(shù)據(jù)類型的類. System.Data.Odbc 包含了操作Odbc數(shù)據(jù)源的類型. System.Data.OracleClient 包含了操作Odbc數(shù)據(jù)庫的類

6、型. System.Transactions 這個命名空間提供了編寫事務性應用程序和資源管理器的一些類. 四、WEB命名空間 System.Web 這個命名空間包含啟用瀏覽器/服務器通信的類和接口.這些命名空間類用于管理到客戶端的HTTP輸出和讀取HTTP請求.附加的類則提供了一些功能,用于服務器端的應用程序以及進程,Cookie管理,文件傳輸,異常信息和輸出緩存的控制. System.Web.UI 這個命名空間包含Web窗體的類,包括Page類和用于創(chuàng)建Web用戶界面的其他標準類. System.Web.UI.HtmlControls 這個命名空間包含用于HTML特定控件的

7、類,這些控件可以添加到Web窗體中以創(chuàng)建Web用戶界面 System.Web.UI.WebControls 包含創(chuàng)建ASP.NET服務器控件的類,當添加到窗體時,這些控件將呈現(xiàn)瀏覽器特定的HTML和腳本,用于創(chuàng)建和設備無關的Web用戶界面. System.Web.Mobile 包含生成ASP.NET移動應用程序所需要的核心功能,包括身份驗證和錯誤處理. System.Web.UI.MobileControls 包括一組ASP.NET服務器控件,這些控件可以針對不同的移動設備呈現(xiàn)應用程序. System.Web.Services 包含能使你使用和生成XMLWebService的類

8、,這些服務是駐留在服務器中的可編程實體,并通過標準Internet協(xié)議公開. 五、框架服務命名空間 System.Diagnostics 這個命名空間所提供的類允許你啟動系統(tǒng)進程,讀取和寫入事件日志以及使用性能計數(shù)器監(jiān)視系統(tǒng)性能. System.DirectoryServices 這個命名空間所提供的類可便于從托管代碼中訪問ActiveDirectory.此命名空間中的類可以與任何ActiveDirectory服務提供程序一起使用. System.Media 包含用于播放聲音文件和訪問系統(tǒng)提供的聲音的類. System.Management 這個命名空間提供的類用于管理一些信

9、息和事件,它們關系到系統(tǒng),設備和WMI基礎結構所使用的應用程序. System.Messaging 這個命名空間提供的類用于連接到網(wǎng)絡上的消息隊列,向隊列發(fā)送消息,從隊列接收或查看消息. System.ServiceProcess 這個命名空間提供的類用于安裝和運行服務,服務是長期運行的可執(zhí)行文件,它們不通過用戶界面來運行. System.Timers 這個命名空間提供基于服務器的計時器組件,用以按指定的間隔引發(fā)事件. 六、安全性命名空間 System.Security 這個命名空間提供公共語言運行庫安全性系統(tǒng)的基礎結構. System.Net.Security 這個命名

10、空間提供用于主機間安全通信的網(wǎng)絡流. System.Web.Security 這個命名空間包含的類用于在Web應用程序中實現(xiàn)ASP.NET安全性. 七、網(wǎng)絡命名空間 System.Net 包含的類可為當前網(wǎng)絡上的多種協(xié)議提供簡單的編程接口. System.Net.Cache 這個命名空間定義了一些類和枚舉,用于為使用WebRequest和HttpWebRequest類獲取的資源定義緩存策略. System.Net.Configuration 這個命名空間包含了以編程方式訪問和更新System.Net命名空間的配置設置的類. System.Net.Mime 這個命名空間包含

11、了用于將電子郵件發(fā)送到SMTP服務器進行傳送的類. System.Net.Networkinformation 這個命名空間提供對網(wǎng)絡流量數(shù)據(jù),網(wǎng)絡地址信息和本地計算機的地址更改通知的訪問,還包含實現(xiàn)Ping實用工具的類.你可以使用Ping和相關的類來檢查是否可通過網(wǎng)絡訪問某臺計算機. System.Net.Sockets 這個命名空間為嚴格控制網(wǎng)絡訪問的開發(fā)人員提供Windows套接字接口的托管實現(xiàn) 八、配置命名空間 System.Configuration 這個命名空間包含用于以編程方式訪問.NetFramework配置設置并處理配置文件中錯誤的類. System.Conf

12、iguration.Assemblies 這個命名空間包含用于配置程序集的類. System.Configuration.Provider 這個命名空間包含由服務器和客戶端應用程序共享,以支持可插接式模型輕松添加或移除功能的基類. 九、本地化命名空間 System.Globalization 包含的類定義與區(qū)域性相關的信息,其中包括語言,國家\地區(qū),所使用的日歷,日期格式的模式,貨幣與數(shù)字以及字符串的排序順序. System.Resources 這個命名空間提供一些類和接口,它們使開發(fā)人員得以創(chuàng)建,存儲并管理應用程序中使用的各種區(qū)域性特定資源. System.Resource

13、s.Tools 這個命名空間包含StronglyTypedResourceBuilder類,該類提供對強類型資源的支持.這個編譯時功能通過創(chuàng)建包含一組靜態(tài)只讀屬性的類封裝對資源的訪問,從而使得使用資源變得更加容易 一. 窗體事件 0. 自動調整窗體 Public xz, yz As Double Public Sub zishiying(ByVal parent As Control) xz = 75 / Form5.Button1.Width yz = 23 / Form5.Button1.Height

14、 Dim sFont As Font For Each c As Control In parent.Controls Dim zihao As Integer = c.Font.Size * xz / 1.2 \ 1 sFont = New Font(c.Font.FontFamily, zihao, c.Font.Style) c.Font = sFont c.Width = c.Width * xz c.Height = c.Height

15、* yz c.Left = c.Left * xz c.Top = c.Top * yz zishiying(c) Next End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click zishiying(Me) End Sub 1.打印文字。 方法一:在窗體上打印文字 Dim g As

16、 Graphics = Me.CreateGraphics Dim mBrush As New SolidBrush(Color.Red) Dim mFont As New Font("宋體", 18) g.DrawString("測試", mFont, mBrush, 0, 10) (0 為橫坐標,10 為縱坐標) 方法二:在窗體上畫文字 Dim m As Graphics m = Me.CreateGraphics m.DrawString("This is a diagonal line draw

17、n on the control", _ New Font("Arial", 10), Brushes.Gold, New PointF(300.0F, 444.0F)) m.Dispose() 方法三:在圖片框上打印文字 Public Class Form2 This example creates a PictureBox control on the form and draws to it. This example assumes that the Form_Load event handler method

18、is connected to the Load eventof the form. Private pictureBox1 As New PictureBox() Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dock the PictureBox to the form andset its background to white. pictureBox1.Dock = Dock

19、Style.Fill pictureBox1.BackColor = Color.White Connect the Paint eventof the PictureBox to the event handler method. AddHandler pictureBox1.Paint, AddressOf Me.pictureBox1_Paint Add the PictureBox control to the Form. Me.Controls.Add(pictureBox1) End Su

20、b Form1_Load 00:00:03.9522260 Private Sub pictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Create a local version of the graphics objectfor the PictureBox. Dim g As Graphics = e.Graphics Draw a stringon the PictureBox.

21、 g.DrawString("This is a diagonal line drawn on the control", _ New Font("Arial", 10), Brushes.Red, New PointF(30.0F, 30.0F)) Draw a line in the PictureBox. g.DrawLine(System.Drawing.Pens.Red, PictureBox1.Left, _ PictureBox1.Top, PictureBox1.Right,

22、 PictureBox1.Bottom) End Sub pictureBox1_Paint End Class 2.關閉窗體 窗體.Dispose 3. 創(chuàng)建一個透明度為75%的窗體 Private Sub CreateMyOpaqueForm() Create a new form. Dim form2 As New Form() Set the text displayed in the caption. form2.Text = "My Form" S

23、et the opacity to 75%. form2.Opacity = 0.75 Size the form to be 300 pixels in height and width. form2.Size = New Size(300, 300) Display the form in the center of the screen. form2.StartPosition = FormStartPosition.CenterScreen Display the fo

24、rm as a modal dialog box. form2.ShowDialog() 4.用代碼在窗體添加一個按鈕. Dim button1 As New Button() Set the button to return a value of OK when clicked. button1.DialogResult = DialogResult.OK Add the button to the form. Controls.Add(button1) butt

25、on1.Text = 123 5.自動生成一個窗體并創(chuàng)建兩個按鈕 (點擊Cancle窗體自動關閉,如果他失去焦點,他不僅會響還會晃) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Create a new instance of the form. Dim form1 As New Form() Create two buttons to use as the accept and

26、cancel buttons. Dim button1 As New Button() Dim button2 As New Button() Set the text of button1 to "OK". button1.Text = "OK" Set the position of the button on the form. button1.Location = New Point(10, 10) Set the text of button2 to "Cancel". button2.Text

27、 = "Cancel" Set the position of the button based on the location of button1. button2.Location = _ New Point(button1.Left, button1.Height + button1.Top + 10) Set the caption bar text of the form. form1.Text = "My Dialog Box" Display a help button on the form.

28、 form1.HelpButton = True Define the border style of the form to a dialog box. form1.FormBorderStyle = FormBorderStyle.FixedDialog Set the MaximizeBox to false to remove the maximize box. form1.MaximizeBox = False Set the MinimizeBox to false to remove the minimize box

29、. form1.MinimizeBox = False Set the accept button of the form to button1. form1.AcceptButton = button1 Set the cancel button of the form to button2. form1.CancelButton = button2 Set the start position of the form to the center of the screen. form1.StartPosition

30、= FormStartPosition.CenterScreen Add button1 to the form. form1.Controls.Add(button1) Add button2 to the form. form1.Controls.Add(button2) Display the form as a modal dialog box. form1.ShowDialog() End Sub 演練:使用 WPF 設計器生成視頻瀏覽器 6.產生此效果 Public Class For

31、m1 Create a new form. Dim mdiChildForm As New Form Dim mdiChildForm1 As New Form Dim mdiChildForm2 As New Form Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Set the IsMdiContainer property to tru

32、e. IsMdiContainer = True Set the child forms MdiParent property to the current form. mdiChildForm.MdiParent = Me mdiChildForm1.MdiParent = Me mdiChildForm2.MdiParent = Me mdiChildForm.Show() mdiChildForm1.Show()

33、mdiChildForm2.Show() mdiChildForm.Text = 1 mdiChildForm1.Text = 2 mdiChildForm2.Text = 3 End Sub End Class 7. 改變窗體的背景顏色 Dim ctl As Control IsMdiContainer = True Loop through controls, looking for controls of MdiClient type.

34、 For Each ctl In Me.Controls If TypeOf (ctl) Is MdiClient Then If the control is the correct type, change the color. ctl.BackColor = System.Drawing.Color.PaleGreen End If Next End Sub 7(2) Private

35、Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click BackColor = System.Drawing.Color.PaleGreen End Sub 或BackColor= Color.Blue 系統(tǒng)顏色: GroupBox3.BackColor = Control.DefaultBackColor 8.繪制橢圓窗體 Dim shape As New System.Drawing.Drawing2D.Graphic

36、sPath shape.AddEllipse(0, 0, Me.Width, Me.Height) Me.Region = New System.Drawing.Region(shape) 9.獲取當前時間 Display the time Text1.Text = Now.ToLongTimeString (只有時間 20 :55 :36) Text1.Text = Now (有日期和時間 2012/1/29 20 :57 :36) Text1.Text = Today (只有日期 2012/1/29) 1

37、0.用鼠標滾輪調整窗體的透明度 Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel Static m As Integer If m > 1 And m <= 100 And e.Delta > 0 Then m = m + 5 ElseIf m > 1 And m <= 100 And e.Delta < 0 Then

38、 m = m - 5 Else m = 100 End If Me.Opacity = m * 0.01 TextBox1.Text = m Me.TopMost = True End Sub 11.絕對坐標 Control.MousePosition.X - 25 Control.MousePosition.Y Control.MousePosition 12.相對坐標 .e.X e.Y 13.調用窗

39、體的Paint事件 Me.Invalidate() 14. 禁用窗體的關閉按鈕 Public Class Form1 Private Declare Function GetSystemMenu Lib "User32" (ByVal hwnd As Integer, ByVal bRevert As Integer) As Integer Private Declare Function RemoveMenu Lib "User32" (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wF

40、lags As Integer) As Integer Private Declare Function DrawMenuBar Lib "User32" (ByVal hwnd As Integer) As Integer Private Declare Function GetMenuItemCount Lib "User32" (ByVal hMenu As Integer) As Integer Private Const MF_BYPOSITION = &H400& Private Const MF_DISABLED = &H2& P

41、rivate Sub disableX(ByVal wnd As Form) Dim hMenu As Integer, nCount As Integer 得到系統(tǒng)Menu hMenu = GetSystemMenu(wnd.Handle.ToInt32, 0) 得到系統(tǒng)Menu的個數(shù) nCount = GetMenuItemCount(hMenu) 去除系統(tǒng)Menu Call RemoveMenu(hMenu, nCount - 1, MF_BYPOSITION O

42、r MF_DISABLED) 重畫MenuBar DrawMenuBar(Me.Handle.ToInt32) End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click disableX(Me) 屏蔽關閉按鈕 End Sub Private Sub Button2_Click(sender As System.Object, e As Syst

43、em.EventArgs) Handles Button2.Click Me.MaximizeBox = False 屏蔽最大化按鈕 End Sub Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click Me.MinimizeBox = False 屏蔽最小化按鈕 End Sub End Class 15.移動窗體 Public Class Form1 Dim x%

44、, y% Private Sub Label1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown x = e.X y = e.Y Timer1.Enabled = True End Sub Sub yidong() Me.Left = Control.MousePosition.X - Label1.Left - x - 9 Me.Top

45、 = Control.MousePosition.Y - Label1.Top - 36 - y End Sub Private Sub Label1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseUp Timer1.Enabled = False End Sub End Class 16.最小化窗體 Me.WindowState = System.Windows.Forms.FormWindowSt

46、ate.Minimized 最小化窗體 17.在窗體的指定位置截取指定的形狀 Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Create a GraphicsPath object and add a rectangle to it. Dim myPath As New System.Drawing.Drawing2D.GraphicsPath() Dim p

47、athRect As New Rectangle(0, 0, 100, 200) myPath.AddRectangle(pathRect) Draw the path to the screen. Dim myPen As New Pen(Color.Black, 2) e.Graphics.DrawPath(myPen, myPath) myGraphicsPath.AddEllipse(New Rectangle(0, 0, 200, 450)) Me.Region = N

48、ew Region(myPath) End Sub 17.完全透明效果 Me.BackColor = Color.White Me.TransparencyKey = Color.White 或 Public Class Form1 Public Structure MARGINS Public cxLeftWidth As Integer Public cxRightWidth As Integer Public cyTopHeight As Integer Public

49、 cyButtomheight As Integer End Structure Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As MARGINS) As Integer End Function Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Me.Tra

50、nsparencyKey = Color.FromArgb(255, 255, 1) Me.BackColor = Me.TransparencyKey Dim margins As MARGINS = New MARGINS margins.cxLeftWidth = -1 margins.cxRightWidth = -1 margins.cyTopHeight = -1 margins.cyButtomheight = -1 DwmExtendFrameIntoC

51、lientArea(Me.Handle, margins) End Sub End Class 18.毛玻璃效果 Imports System.Runtime.InteropServices Public Class Form1 Vista與Windows 7中的Aero界面是它們最吸引人的新功能之一,它可以實現(xiàn)大面積的透明界面。但是我們在編程中卻不能完全利用這個功能。雖然VB.Net 2005以后的控件已經(jīng)開始支持XP和Vista的風格了,但是窗體的界面卻無法完全實現(xiàn)Aero的毛玻璃效果,只有最外面的一層窗口標題欄是透明的。網(wǎng)上確實有關于如何用.Net

52、語言來實現(xiàn)這一效果的,但那是C#,而不是VB.Net。要VB.Net語言來實現(xiàn)?在網(wǎng)上找不到。難道為了這個功能非得去學C#才行嗎?雖然網(wǎng)上有將C#代碼轉換為VB.Net代碼,但它要求完整的代碼結構,而網(wǎng)上提供的往往只是一段代碼,并不是完整的一個Class,所以也難實現(xiàn)。本文將講述如何用做這個界面。 Aero毛玻璃界面之所以無法在的IDE中直接使用,是因為它是Vista和Win7專有的功能,XP是不可能實現(xiàn)的。這個功能被放在了Vista和Win7的系統(tǒng)目錄中的一個API庫中,它就是DWMAPI.DLL.所以如果我們要做這種窗口,首先要調用這個API。 在程序開頭導入這個,

53、否則會出錯 聲明函數(shù)和必要的類型,在Class <類名稱> 后面輸入 _ Public Structure MARGINS Public cxLeftWidth As Integer Public cxRightWidth As Integer Public cyTopHeight As Integer Public cyButtomheight As Integer End Structure

54、 _ Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As MARGINS) As Integer End Function Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Me.TransparencyKey = Co

55、lor.FromArgb(255, 255, 1) Me.BackColor = Me.TransparencyKey Dim margins As MARGINS = New MARGINS margins.cxLeftWidth = -1 margins.cxRightWidth = -1 margins.cyTopHeight = -1 margins.cyButtomheight = -1 DwmExtendFrameIntoClientArea(Me.Hand

56、le, margins) End Sub End Class 二.系統(tǒng)事件 0.系統(tǒng)監(jiān)控 Imports System.IO Private Sub FileSystemWatcher1_Changed(sender As Object, e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed FileSystemWatcher1.NotifyFilter = IO.NotifyFilters.LastWrite lujing = e.Ful

57、lPath.ToString End Sub 1.系統(tǒng)睡覺 System.Threading.Thread.Sleep(9000) 2.調用.exe程序 1.指定路徑: i = Shell("E:\vb2010.exe", 1) 2.相對路徑: i = Shell("定時關機.exe", 1) (直接彈出) i = Shell("定時關機.exe", 2) (直接隱藏在任務欄) i = Shell("定時關機.exe",3) (以最大化方式彈出) 3.右鍵菜單的彈出 Private Sub Label4

58、_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label4.MouseClick If e.Button = Windows.Forms.MouseButtons.Right Then mnulabel4.Visible = True mnulabel4.Left = e.X + Me.Left +( Label4)對象.Left + 8 mnulabel4.Top = e.Y + Me.Top +( L

59、abel4)對象.Top + 35 End Sub 4.dll文件的調用 如何引用C++寫DLL文件?及函數(shù)的調用方法? C++函數(shù)如下: bool winapi connectplayserver ( char* address, DWORD Port, DWORD DataPart, char* Username ) 引用C++寫DLL文件及函數(shù)的方法? Private Shared Function ConnectPlayServer(ByVal Address As Str

60、ing, 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 例如: Typedef struct xtest { char a[100]; char b[100]; }*px; __declspec(dllexport) void _

61、_stdcall test (*px,char *x,char *y); void __stdcall test (*px,char *x,char *y) { if(strlen(x)>100) *(x+99)=\0; if(strlen(y)>100)*(y+99)=\0; strcpy(px->a,x); strcpy(px->b,y); return; } 在vb里你要寫一個同樣的結構 Public Structure xtest Public a As String Publi

62、c b As String End Structure public declare funciton test lib"你的dll名字" (byref px as xtest,byval x,byval y) 三.對話框 1.打開文件 Set the Open dialog properties With OpenFileDialog1 .Filter = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*" .FilterIndex = 1

63、 .Title = "打開文件" End With Show the Open dialog and if the user clicks the Open button, load the file If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then 或 If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.Cancel Then

64、 Try Save the file path and name strFileName = OpenFileDialog1.FileName Dim fileContents As String fileContents = My.Computer.FileSystem.ReadAllText(strFileName) Display the file contents in the text b

65、ox Text1.Text = fileContents Catch ex As Exception MessageBox.Show(ex.Message, My.Application.Info.Title, _ MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End If 或 獲取文件的絕對路徑 OpenFileDialog1.ShowDialog(

66、) AxShockwaveFlash1.Movie = OpenFileDialog1.FileName 2.保存文件 With SaveFileDialog1 獲?取?或設置?默?認?文?件t的?擴?展1名? .DefaultExt = "txt" .FileName = strFileName 文?件t類型篩?選? .Filter = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*" .FilterIndex = 1 如?果?用?戶指?定的?

展開閱讀全文
溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

相關資源

更多
正為您匹配相似的精品文檔

相關搜索

關于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權所有   聯(lián)系電話:18123376007

備案號:ICP2024067431-1 川公網(wǎng)安備51140202000466號


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對上載內容本身不做任何修改或編輯。若文檔所含內容侵犯了您的版權或隱私,請立即通知裝配圖網(wǎng),我們立即給予刪除!