- DBNull.Value
- DbDataReader的IsDbNull
開發win CE
Windows Mobile 5.0 Developer Resource Kit (8xxMB)
包含:
- Mobile 5.0 SDK for PPC
- Mobile 5.0 SDK for Smart Phone
- VS 2005 Express
- Sample Code
- 還有一些 Tools
HASH
方法一:使用fileOpen、fileGet、filePut、fileClose
‘先定義資料結構
Structure RowOBS04
Dim TDATE As String ‘交易日期
Dim ITEM_ID As String ‘貨品代碼
Dim KIND_ID As String ‘品種代碼
Dim ITEM_NAME As String ‘貨品名稱
Dim KIND_NAME As String ‘品種名稱
Dim ITEM_CAT As String ‘產品分類
Dim KIND_CAT As String ‘品種分類
End Structuresub GETDATA()
Dim Cusdat As RowOBS04
Dim fileNumber As Integer = FreeFile()FileOpen(fileNumber, fileName, OpenMode.Random)
FileGet(fileNumber, Cusdat, CInt(TextBox1.Text))
FileClose(fileNumber)
TextBox2.Text = Cusdat.TDATE
TextBox3.Text = Cusdat.ITEM_ID
TextBox4.Text = Cusdat.KIND_ID
TextBox5.Text = Cusdat.ITEM_NAME
TextBox6.Text = Cusdat.KIND_NAME
TextBox7.Text = Cusdat.ITEM_CAT
TextBox8.Text = Cusdat.KIND_CAT
end sub
sub SETDATA()
Dim Cusdat As RowOBS04
Dim fileNumber As Integer = FreeFile()FileOpen(fileNumber, fileName, OpenMode.Random)
‘UPDATE資料
Cusdat.TDATE = TextBox2.Text
Cusdat.ITEM_ID = TextBox3.Text
Cusdat.KIND_ID = TextBox4.Text
Cusdat.ITEM_NAME = TextBox5.Text
Cusdat.KIND_NAME = TextBox6.Text
Cusdat.ITEM_CAT = TextBox7.Text
Cusdat.KIND_CAT = TextBox8.Text
FilePut(fileNumber, Cusdat, CInt(TextBox1.Text))
FileClose(fileNumber)
end sub
方法二:system.io.file
1.定義一筆RecordLen
2.計算位置=(筆數-1)*RecordLen3.三種方式[適情況而定]
(1)索引條件為數字,且知道數字不大
==================
item_id | item_Name | kind
0070
0071
.
.
.
9999
====================
以上這種情況,可以用數字直接作索引條件,71塞到71的位置,73塞到73的位置,如72沒資料就留一筆RecordLen空白(2)索引條件為數字,但數字大
建索引(也是一個文字檔)
no為item_id除某一質數的餘數
record_no為實際位置
==========================
[餘數出現重覆情況則放後面,如超過預計放置筆數,則用FLAG記錄之後從哪個NO開始]
no | item_id | record_no | item_id | record_no | item_id | record_no | flag
1 0000070 1
2 0000071 2
.
.
.
100 0071000 20000
.
.
.
==========================(3)索引條件不一定為數字
如出現字母,則可把字母排除,或把字母轉為數字來進行INDEX
Property的寫法
Class Class1
'Define a local variable to store the property value.
Private propertyValue As String
'Define the property.
Public Property prop1() As String
Get
'The Get property procedure is called when the value
'of a property is retrieved.
Return propertyValue
End Get
Set(ByVal value As String)
'The Set property procedure is called when the value
'of a property is modified. The value to be assigned
'is passed in the argument to Set.
propertyValue = value
End Set
End Property
End Class
Structure的寫法
Public Structure employee
'Public members, accessible from throughout declaration region.
Public firstName As String
Public middleName As String
Public lastName As String
'Friend members, accessible from anywhere within the same assembly.
Friend employeeNumber As Integer
Friend workPhone As Long
'Private members, accessible only from within the structure itself.
Private homePhone As Long
Private level As Integer
Private salary As Double
Private bonus As Double
'Procedure member, which can access structure’s private members.
Friend Sub calculateBonus(ByVal rate As Single)
bonus = salary * CDbl(rate)
End Sub
'Property member to return employee’s eligibility.
Friend ReadOnly Property eligible() As Boolean
Get
Return level >= 25
End Get
End Property
'Event member, raised when business phone number has changed.
Public Event changedWorkPhone(ByVal newPhone As Long)
End Structure
Timer有三種
.Net 有三種計時器
System.Timers.Timer 使用 Elapsed 事件
System.Windows.Forms.Timer 使用 Tick
System.Threading.Timer 使用 CallBack Function
Timer的用法
sub main()
Dim Timer1 As New System.Timers.Timer
AddHandler Timer1.Elapsed, New System.Timers.ElapsedEventHandler(AddressOf Timer1_Elapsed)
Timer1.Interval = 10000
Timer1.Enabled = True
Timer1.AutoReset = False
End Sub
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs)
MsgBox(”OK”)
End Sub
用表單名開啟FORM
Public Function OpenForm(ByVal FormName As String) As Form
Dim mainAssembly As System.Reflection.Assembly = & _
System.Reflection.Assembly.GetExecutingAssembly
Dim objNewForm As Object = & _
Activator.CreateInstance(Type.GetType(mainAssembly.GetName.Name + "." + FormName))
Return DirectCast(objNewForm, Form)
End Function
TableAdapter = DataTable + DataAdapter
這是.NET 2.0的新玩意,結合既有的dataset,只要拉一拉,新增修改刪除的功能就完成了,
真的就是那麼誇張,但我現在還在摸索中…..
dataset功力大增…..