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
安裝WordPress亂碼問題
WORDPRESS的升級
之前APACHE的LOG一直出現錯誤訊息,就是找不到解決的方法,
6/4晚上一時興起,換灌新版的APACHE+PHP,也把WORDPRESS升到2.2版,
但遇到亂碼的問題了…
———————————————————-
[mysqld]
default-character-set=utf8
寫到家目錄下的~/.my.cnf。
另外,還要修改 wp-includes/wp-db.php,找到
$this->dbh=@mysql_connect($dbhost,$dbuser,$dbpassword);
在底下多加一行
$this->query(“SET NAMES ‘utf8′”);
這樣就可以解決亂碼的問題了。
題外話,如果想把WordPress的語系環境設成中文的話,可以先下載中文語系檔,解開之後把zh_TW.mo放到 wp-includes/languages(如果沒有這個目錄的話要自己建立)底下,接著在安裝之前修改wp-config.php,把原本的
define (‘WPLANG’,”);
改成
define (‘WPLANG’,’zh_TW’);
就可以了。
Health Monitoring
ASP.Net 2.0提供了Health Monitoring讓你只要透過設定檔就可以將錯誤記錄下來,
.Net 2.0開始使用大量的provider modal,
而Health Monitoring也不例外,
它提供了六個provider:
- SimpleMailWebEventProvider. 發信通知您錯誤事件.
- TemplatedMailWebEventProvider. 同樣是發信,不過你可以使用模版來設定信件的畫面格式.
- SqlWebEventProvider. 將錯誤紀錄到SQL資料庫中,如果要使用這個provider,你需要先使用”aspnet_regsql.exe -E -S <ServerName> -A w “建立資料結構,然後再用Aspnet_regiis.exe將web.config中的連線字串加密.
- EventLogWebEventProvider. 將錯誤事件記錄到事件檢視器中.
- TraceWebEventProvider. 將事件記錄在ASP.NET trace messages.
- WmiWebEventProvider. 將ASP.Net health monitoring事件整合到Windows Management Instrumentation (WMI) events. 閱讀全文 “Health Monitoring”
用表單名開啟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功力大增…..
在雙螢幕系統中如何指定WinForm在指定的螢幕出現
下列的程式片段可以幫你把WinForm搬到第一個非主要的螢幕
Private Sub MoveToNonPrimaryScreen()
For Each MyScreen As Screen In Screen.AllScreens '對所有的螢幕
If Not MyScreen.Primary Then '找到不是主要的第一個螢幕
bPanelFrom.Show()
bPanelFrom.Left = MyScreen.WorkingArea.X '把自己的位置長寬與該螢幕設的一樣
bPanelFrom.Top = MyScreen.WorkingArea.Y
bPanelFrom.Width = MyScreen.WorkingArea.Width
bPanelFrom.Height = MyScreen.WorkingArea.Height
Exit For
End If
Next
End Sub
『FPS Awesome Marquee』
它是一個.Net Framework的元件,是由 FreezePro Software所寫出來的,而且是免費的它不用Timer元件就能產生文字跑馬燈的效果,而且已經把很多特效列為屬性了,例如:
- 文字移動的方向(上、下、左、右 )
- 文字的漸層顏色(可以選擇開始顏色跟結束顏色)
- 網格(可以控制格子的大小跟線的粗細,線的顏色)
- 文字移動的速度(預設是100)
- 文字閃爍的功能(這個我怎麼試都出不來,還可以設定閃的速度)
- 文字的透明度(不過背景還是不能設透明…Orz)
雖然有些小缺點,不過實在是很方便的一個元件,重點又是免費..
想試試的人可以到Download下載,它有分.NET 1.1跟.NET 2.0的版本