2008年4月18日

HOW TO:辨識 Visual Basic HTML 字串中的文字

資料來源處:http://msdn2.microsoft.com/zh-tw/library/ms235379(VS.80).aspx
HOW TO:辨識 Visual Basic HTML 字串中的文字

這個範例會使用簡單的規則運算式 (Regular Expression) 移除 HTML 文件的標記。

範例
HTML 標記會與規則運算式 \<[^\>]+\> 相符,這表示:

字元 "<",之後接著 一或多個字元集合,不包括 ">" 字元,之後接著

字元 ">"。

這個範例會使用共用的 System.Text.RegularExpressions.Regex.Replace(System.String,System.String,System.String) 方法,以使用空字串取代標記規則運算式的所有符合項。

''' Removes the tags from an HTML document.
''' HTML text to parse.
''' The text of an HTML document without tags.
'''
Function GetTextFromHtml(ByVal htmlText As String) As String
Dim output As String = Regex.Replace(htmlText, "\<[^\>]+\>", "")
Return output
End Function

這個範例要求您必須使用 Imports 陳述式,匯入 System.Text.RegularExpressions 命名空間。如需詳細資訊,請參閱 Imports 陳述式

2008年4月9日

XML VB.NET Examples

資料來源處:http://www.example-code.com/vbdotnet/xml.asp
SSSSS

繪製統計圖表不求人

資料來源處:http://cpro.com.tw/channel/pcpro/content/index.php?news_id=8652

在 Windows Forms 列印報表

資料來源處:https://www.microsoft.com/taiwan/msdn/library/2003/May-2003-tw/printwinforms.htm

如何存取一個 Windows Form 在另一個 Windows Form 的成員藉由使用 Visual Basic . NET 或 Visual Basic 2005

資料來源處:http://support.microsoft.com/kb/841292/zh-tw

2008年4月7日

[ASP.Net]DataSet新增資料(DataRow)並透過xml格式儲存讀寫

[ASP.Net]DataSet新增資料(DataRow)並透過xml格式儲存讀寫




--------------------------------------------------------------------------------
try
{
//建立儲存選取之mailing List DataSet
DataSet ds = new DataSet();
ds.Tables.Add("CHECKED"); //新增CHECKED資料表至DATASET ds之中
ds.Tables["CHECKED"].Columns.Add("STU_ID"); //新增欄位STU_ID至DATASET ds之中
ds.Tables["CHECKED"].Columns.Add("STU_NAME");
ds.Tables["CHECKED"].Columns.Add("CMP_NAME");
ds.Tables["CHECKED"].Columns.Add("EMAIL");
for(int i = 0; i {
HtmlInputCheckBox app_no = (HtmlInputCheckBox)dgEmail.Items[i].FindControl("chkSTU_ID");

if(app_no.Checked)
{
System.Data.DataRow row = ds.Tables["CHECKED"].NewRow();

row["STU_ID"]=dgEmail.Items[i].Cells[6].Text; //由dgEmail這個DataGrid新增學生編號
row["STU_NAME"]=dgEmail.Items[i].Cells[0].Text;
row["CMP_NAME"]=dgEmail.Items[i].Cells[1].Text;
row["EMAIL"]=dgEmail.Items[i].Cells[4].Text;

ds.Tables["CHECKED"].Rows.Add(row);
}
}
//將建立之mailing List DataSet的資料寫入 mailList.xml 檔案
ds.WriteXml(Server.MapPath(Config.Document.Training_Education)+ "/mailList.xml",XmlWriteMode.WriteSchema);
ds.Dispose();
}
catch(Exception ex)
{
Response.Write(ex.Message);
}


--------------------------------------------------------------------------------


--------------------------------------------------------------------------------

DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath(Config.Document.Training_Education)+"/mailList.xml");

2008年4月5日

HOW TO:建立縮圖影像

資料來源處: http://msdn2.microsoft.com/zh-tw/library/ets0sayh(vs.80).aspx

HOW TO:建立縮圖影像
縮圖影像是影像的縮小版本。您可以藉由呼叫 Image 物件的 GetThumbnailImage 方法來建立縮圖影像。

下列範例會從 Compass.bmp 檔案建構 Image 物件。原始影像的寬度為 640 個像素,高度為 479 個像素。程式碼會建立寬度為 100 個像素,高度為 100 個像素的縮圖影像。
下圖顯示的是縮圖影像。

Dim image As New Bitmap("Compass.bmp")
Dim pThumbnail As Image = image.GetThumbnailImage(100, 100, Nothing, _
New IntPtr())
e.Graphics.DrawImage( _
pThumbnail, _
10, _
10, _
pThumbnail.Width, _
pThumbnail.Height)

2008年3月31日

How To Use Splitters Controls [ Splitters ]

範例1:


6. How To Use Splitters Controls [ Splitters ]
An Example:



1. Draw a panel on the form

2. Draw a textbox on the panel ( TextBox1.width is ( 1/2 Panel1.width ) )

3. Set TexBox1's Dock property to Left

4. Draw a splitter on the panel and set its Dock property to Left

5. Run Your Application

6. Now resize your TextBox1 by dragging the splitter


範例2:
An Explorer-Style Application
You are attempting to produce an interface in the format of the Windows Explorer, Outlook, and other applications. This interface will have a TreeView along one side of the form and a ListView on the other, and have the capability to move the dividing line between the two controls to resize them (see Figure 3.17).



Figure 3.17

The standard Explorer style of form layout.

This style of layout is easy to accomplish with the new features of Windows forms, but the specific order in which you add items to your form is important.

Starting with a blank form, add a TreeView control and set its Dock property to Left.
Add a Splitter control; it will automatically dock to the left and take its place along the right side of the TreeView.
Add a ListView control and set its Dock property to Fill.
That's it. The ListView will fill whatever space isn't being used by the TreeView and the Splitter will allow you to adjust the relative size of the two areas.

That is all of the sample resizing scenarios covered in this chapter, but that certainly is not the extent of layouts that can be created.

2008年3月29日

具名參回方式,存取資料庫

連接SQL.
connStr = "Server=(local); database=票據; uid=sa; pwd=;"
conn = New SqlConnection(connStr)
conn.Open()
updateCmd = "update 廠商 Set C_Co=@公司 ,C_LTD=@簡稱 Where C_No=@編號"
cmd = New SqlCommand(updateCmd, conn)
cmd.Parameters.Add(New SqlParameter("@編號", SqlDbType.Char))
cmd.Parameters.Add(New SqlParameter("@公司", SqlDbType.Char))
cmd.Parameters.Add(New SqlParameter("@簡稱", SqlDbType.Char))
cmd.Parameters("@編號").Value = txtC_No.Text
cmd.Parameters("@公司").Value = txtC_Co.Text
cmd.Parameters("@簡稱").Value = txtC_LTD.Text
cmd.ExecuteNonQuery()

連接Access.
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=票據.mdb"
conn = New OleDbConnection(connStr)
conn.Open()
updateCmd = "update 廠商 Set C_Co=@公司 ,C_LTD=@簡稱 Where C_No=@編號"
cmd = New OleDbCommand(updateCmd, conn)
cmd.Parameters.Add(New OleDbParameter("@編號", OleDbType.Char))
cmd.Parameters.Add(New OleDbParameter("@公司", OleDbType.Char))
cmd.Parameters.Add(New OleDbParameter("@簡稱", OleDbType.Char))
cmd.Parameters("@編號").Value = txtC_No.Text
cmd.Parameters("@公司").Value = txtC_Co.Text
cmd.Parameters("@簡稱").Value = txtC_LTD.Text
cmd.ExecuteNonQuery()

結果 :
SQL 版,完全正常
Access版則會存成 ==> 公司(C_Co)會存到編號(C_No),簡稱(C_LTD)會存到公司(C_Co)的資料 !?
請教高手,何處錯了,謝謝指導~


以上問題已ok了 ~
在SQL語法中的順序是=>公司、簡稱、編號,所以我將具名參數的順序也修改成=>公司、簡稱、編號即ok了,如下:
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=票據.mdb"
conn = New OleDbConnection(connStr)
conn.Open()
updateCmd = "update 廠商 Set C_Co=@公司 ,C_LTD=@簡稱
Where C_No=@編號"
cmd = New OleDbCommand(updateCmd, conn)
cmd.Parameters.Add(New OleDbParameter("@公司",
OleDbType.Char))
cmd.Parameters.Add(New OleDbParameter("@簡稱",
OleDbType.Char))
cmd.Parameters.Add(New OleDbParameter("@編號",
OleDbType.Char))
cmd.Parameters("@公司").Value = txtC_Co.Text
cmd.Parameters("@簡稱").Value = txtC_LTD.Text
cmd.Parameters("@編號").Value = txtC_No.Text
cmd.ExecuteNonQuery()

#問題是在SQL server 2000怎沒順序問題 ? 好奇怪 @#$%

2008年3月27日

如何重新註冊 Windows 主從式架構在 WSUS

重新註冊 Windows 主從式架構在 WSUS

如果要重新登錄 Windows 主從式架構在 WSUS 檢閱下列指示:

1. 在 Windows 主從式架構 WSUS 中具有一個註冊問題執行 「 gpupdate / force 」 命令。

在 Windows 主從式架構 WSUS 中具有一個註冊問題 2. 執行 " wuauclt /detectnow 」 命令。


秘訣: 您可以使用 [ 事件檢視器來檢閱重新註冊

疑難排解工具

http://www.microsoft.com/technet/prodtechnol/sbs/2003/support/documentation/53979bbb-3099-44ac-98bc-097959ac8b5c.mspx?mfr=true

3. 在極少數情況下, 您可能會要執行: " wuauclt.exe /resetauthorization /detectnow 」 命令

Windows 主從式架構 WSUS 中具有一個註冊問題上的指令。


http://support.microsoft.com/kb/555974/zh-tw