2007-02-22

Operate XML

載入檔案
Dim XMLFileName As String = "File name here"
XMLDoc As New Xml.XmlDocument
XMLDoc.Load(XMLFileName)
 
取得節點
XMLNode As Xml.XmlNode
XMLNode = XMLDoc.SelectSingleNode("MakeMoneySystem/ShippingLabel")
p.s 如果node不存在, XMLNode=Nothing
 
新增節點
Dim root As Xml.XmlNode = XMLDoc.DocumentElement
Dim elem As Xml.XmlElement = XMLDoc.CreateElement("節點名稱")
elem.SetAttribute("屬性名稱", "值")
elem.InnerText = "節點值"
root.AppendChild(elem)
XMLDoc.Save(XMLFileName)
 
取得屬性值
XMLNode.Attributes.ItemOf("屬性名稱").Value
 
新增屬性
Dim NewAttr As Xml.XmlAttribute = XMLDoc.CreateAttribute("屬性名稱")
NewAttr.Value = "屬性值"
XMLNode.Attributes.SetNamedItem(NewAttr)
XMLDoc.Save(XMLFileName)

Get image from Web

Dim Req As Net.HttpWebRequest = Net.WebRequest.Create("Img Src")
Dim Res As Net.HttpWebResponse = Req.GetResponse
Dim TheStream As IO.Stream = Res.GetResponseStream()
Dim TheImg As Bitmap = New Bitmap(TheStream)
TheImg.Save("File name")
TheStream.Close()

2007-02-16

取得程式執行位置

在程式執行中 Application.StartupPath
在ApplicationEvents中 Application.Info.DirectoryPath

2007-02-12

Barcode notification

列印Barcode時, 在barcode的前後必需加上"*"做為開始及結束的符號("*"同時也需轉成barcode字型)
這樣列印出來的barcode才會掃得到
 
3 of 9字型尺寸
12 , 18 , 24 , 36 , 48 , 60 , 72

2007-02-02

跨執行緒存取控制項

您可以藉由將 CheckForIllegalCrossThreadCalls 屬性值設定為 false,停用這個例外狀況。這會造成您的控制項使用在 Visual Studio 2003 下執行的相同方式來執行。
Control.CheckForIllegalCrossThreadCalls = false