PIXNET Logo登入

M的部落格

跳到主文

歡迎光臨M在痞客邦的小天地

部落格全站分類:不設分類

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 10月 08 週二 201311:39
  • [VB.Net][使用使用CDONTS.NewMail 發送Mail]

Imports System.Data
Imports System.Net.Mail
Imports System.IO
(繼續閱讀...)
文章標籤

M 發表在 痞客邦 留言(0) 人氣(161)

  • 個人分類:VB.Net
▲top
  • 10月 08 週二 201311:29
  • [其他][ASCII字碼表]





16




10




位


元




16




10




位


元




16




10




位


元




16




10




位


元




16




10




位


元




16




10




位


元




16




10




位


元




16




10




位


元






0




0




 




10




16



 

20




32




 




30




48




0




40




64




@




50




80




P




60




96




`




70




112




p






1




1




 




11




17







21




33




!




31




49




1




41




65




A




51




81




Q




61




97




a




71




113




q






2




2




 




12




18







22




34




"




32




50




2




42




66




B




52




82




R




62




98




b




72




114




r






3




3




 




13




19







23




35




#




33




51




3




43




67




C




53




83




S




63




99




c




73




115




s






4




4




 




14




20







24




36




$




34




52




4




44




68




D




54




84




T




64




100




d




74




116




t






5




5




 




15




21







25




37




%




35




53




5




45




69




E




55




85




U




65




101




e




75




117




u






6




6




 




16




22



 

26




38




&




36




54




6




46




70




F




56




86




V




66




102




f




76




118




v






7




7




 




17




23



 

27




39




'




37




55




7




47




71




G




57




87




W




67




103




g




77




119




w






8




8




 




18




24



 

28




40




(




38




56




8




48




72




H




58




88




X




68




104




h




78




120




x






9




9




..




19




25



 

29




41




)




39




57




9




49




73




I




59




89




Y




69




105




i




79




121




y






A




10




..




1A




26




..




2A




42




*




3A




58




:




4A




74




J




5A




90




Z




6A




106




j




7A




122




z






B




11




 




1B




27



 

2B




43




+




3B




59




;




4B




75




K




5B




91




[




6B




107




k




7B




123




{






C




12




 




1C




28







2C




44




,




3C




60




< 




4C




76




L




5C




92




\




6C




108




l




7C




124




|






D




13




..




1D




29



 

2D




45




-




3D




61




=




4D




77




M




5D




93




]




6D




109




m




7D




125




}






E




14





 




1E




30




‑




2E




46




.




3E




62




> 




4E




78




N




5E




94




^




6E




110




n




7E




126




~






F




15



 

1F




31




­




2F




47




/




3F




63




?




4F




79




O




5F




95




_




6F




111




o




7F




127










(繼續閱讀...)
文章標籤

M 發表在 痞客邦 留言(0) 人氣(129)

  • 個人分類:VB.Net
▲top
  • 10月 08 週二 201311:26
  • [VB.Net][連線錯誤訊息]

'連線錯誤訊息
[Login Failed.  Check for valid user ID, server name and password  Native Error code: 4002]
解決方式:
(繼續閱讀...)
文章標籤

M 發表在 痞客邦 留言(0) 人氣(72)

  • 個人分類:VB.Net
▲top
  • 10月 08 週二 201311:04
  • [VB.Net][DBF檔匯入語法]


 
<script src="https://gist.github.com/michaelctwk/a80b3983812b77ea23e7.js"></script>
 
(繼續閱讀...)
文章標籤

M 發表在 痞客邦 留言(0) 人氣(238)

  • 個人分類:VB.Net
▲top
  • 10月 08 週二 201311:03
  • [VB.Net][使用javascript onkeypress事件]

<script language="javascript">
  function checkInput() {
(繼續閱讀...)
文章標籤

M 發表在 痞客邦 留言(0) 人氣(72)

  • 個人分類:VB.Net
▲top
  • 10月 08 週二 201311:01
  • [VB.Net][防止按鈕重複按]

 
注意調整Form1
 
 
(繼續閱讀...)
文章標籤

M 發表在 痞客邦 留言(0) 人氣(269)

  • 個人分類:VB.Net
▲top
  • 10月 08 週二 201310:56
  • [VB.Net][使用ICSharpCode.SharpZipLib.dll元件處理壓縮]

步驟一:加入[ICSharpCode.SharpZipLib.dll]元件
步驟二:將下列程式加入Class




Imports System


Imports System.Collections.Generic


Imports System.Text


Imports System.IO


Imports ICSharpCode.SharpZipLib.Zip


 


Public Class Zip


 


    ''' <summary>


    ''' 壓縮整個資料夾


    ''' </summary>


    ''' <param name="SourceDir">要壓縮的資料夾(完整路徑) </param>


    ''' <param name="TargetFile">要產生的Zip檔案(完整路徑檔名)</param>


    ''' <param name="Password">密碼</param>


    ''' <param name="BackupOldFile">是否備份舊檔案</param>


    Public Sub ZipDir(ByVal SourceDir As String, ByVal TargetFile As String, ByVal Password As String, ByVal BackupOldFile As Boolean)


        Dim oZipDir As New ICSharpCode.SharpZipLib.Zip.FastZip()


        Try


            If Not Directory.Exists(SourceDir) Then


                Throw New Exception("資料夾不存在!")


            End If


 


            If BackupOldFile = True Then


                '判斷要產生的ZIP檔案是否存在


                If File.Exists(TargetFile) = True Then


                    '原本的檔案存在,把他ReName


                    File.Copy(TargetFile, TargetFile & "-" & DateTime.Now.ToString("yyyyMMddHHmmss") & ".back")


                    File.Delete(TargetFile)


                End If


            End If


 


            If Password <> "" Then


                oZipDir.Password = Password


            End If


            oZipDir.CreateZip(TargetFile, SourceDir, True, "")


        Catch


            Throw


        End Try


    End Sub


 


    ''' <summary>


    '''壓縮整個資料夾


    ''' </summary>


    ''' <param name="SourceDir">要壓縮的資料夾(完整路徑) </param>


    ''' <param name="TargetFile">要產生的Zip檔案(完整路徑檔名)</param>


    ''' <param name="Password">密碼</param>


    Public Sub ZipDir(ByVal SourceDir As String, ByVal TargetFile As String, ByVal Password As String)


        Me.ZipDir(SourceDir, TargetFile, Password, True)


    End Sub


 


    ''' <summary>


    '''壓縮整個資料夾


    ''' </summary>


    ''' <param name="SourceDir">要壓縮的資料夾(完整路徑) </param>


    ''' <param name="TargetFile">要產生的Zip檔案(完整路徑檔名)</param>


    Public Sub ZipDir(ByVal SourceDir As String, ByVal TargetFile As String)


        Me.ZipDir(SourceDir, TargetFile, "", True)


    End Sub


 


    ''' <summary>


    ''' 壓縮檔案


    ''' </summary>


    ''' <param name="SourceFiles">要壓縮的檔案(完整路徑)</param>


    ''' <param name="TargetFile">要產生的Zip檔案(完整路徑檔名)</param>


    ''' <param name="Password">密碼</param>


    ''' <param name="BackupOldFile">是否備份舊檔案</param>


    Public Sub ZipFiles(ByVal SourceFiles As String(), ByVal TargetFile As String, ByVal Password As String, ByVal BackupOldFile As Boolean)


        Try


            If SourceFiles Is Nothing OrElse SourceFiles.Length <= 0 Then


                Throw New Exception("並未傳入檔案完整路徑")


            End If


 


            For i As Integer = 0 To SourceFiles.Length - 1


                If File.Exists(SourceFiles(i)) = False Then


                    Throw New Exception("要壓縮的檔案【" & SourceFiles(i) & "】不存在")


                End If


            Next


 


            If BackupOldFile = True Then


                '判斷要產生的ZIP檔案是否存在


                If File.Exists(TargetFile) = True Then


                    '原本的檔案存在,把他ReName


                    File.Copy(TargetFile, TargetFile & "-" & DateTime.Now.ToString("yyyyMMddHHmmss") & ".back")


                    File.Delete(TargetFile)


                End If


            End If


 


            Dim zs As New ZipOutputStream(File.Create(TargetFile))


            zs.SetLevel(9)


            '壓縮比


            If Password <> "" Then


                zs.Password = Password


            End If


 


            For i As Integer = 0 To SourceFiles.Length - 1


                Dim s As FileStream = File.OpenRead(SourceFiles(i))


                Dim buffer As Byte() = New Byte(s.Length - 1) {}


                s.Read(buffer, 0, buffer.Length)


                Dim Entry As New ZipEntry(Path.GetFileName(SourceFiles(i)))


                Entry.DateTime = DateTime.Now


                Entry.Size = s.Length


                s.Close()


                zs.PutNextEntry(Entry)


                zs.Write(buffer, 0, buffer.Length)


            Next


            zs.Finish()


            zs.Close()


        Catch


            Throw


        End Try


    End Sub


 


    ''' <summary>


    ''' 壓縮檔案


    ''' </summary>


    ''' <param name="SourceFiles">要壓縮的檔案(完整路徑)</param>


    ''' <param name="TargetFile">要產生的Zip檔案(完整路徑檔名)</param>


    ''' <param name="Password">密碼</param>


    Public Sub ZipFiles(ByVal SourceFiles As String(), ByVal TargetFile As String, ByVal Password As String)


        Me.ZipFiles(SourceFiles, TargetFile, Password, True)


    End Sub


 


    ''' <summary>


    ''' 壓縮檔案


    ''' </summary>


    ''' <param name="SourceFiles">要壓縮的檔案(完整路徑)</param>


    ''' <param name="TargetFile">要產生的Zip檔案(完整路徑檔名)</param>


    Public Sub ZipFiles(ByVal SourceFiles As String(), ByVal TargetFile As String)


        Me.ZipFiles(SourceFiles, TargetFile, "", True)


    End Sub


 


    ''' <summary>


    ''' 壓縮單一檔案


    ''' </summary>


    ''' <param name="SourceFiles">要壓縮的檔案(完整路徑)</param>


    ''' <param name="TargetFile">要產生的Zip檔案(完整路徑檔名)</param>


    ''' <param name="Password">密碼</param>


    ''' <param name="BackupOldFile">是否備份舊檔案</param>


    Public Sub ZipFile(ByVal SourceFile As String, ByVal TargetFile As String, ByVal Password As String, ByVal BackupOldFile As Boolean)


        Me.ZipFiles(New String() {SourceFile}, TargetFile, Password, BackupOldFile)


    End Sub


 


    ''' <summary>


    ''' 壓縮單一檔案


    ''' </summary>


    ''' <param name="SourceFiles">要壓縮的檔案(完整路徑)</param>


    ''' <param name="TargetFile">要產生的Zip檔案(完整路徑檔名)</param>


    ''' <param name="Password">密碼</param>


    Public Sub ZipFile(ByVal SourceFile As String, ByVal TargetFile As String, ByVal Password As String)


        Me.ZipFile(SourceFile, TargetFile, Password, True)


    End Sub


 


    ''' <summary>


    ''' 壓縮單一檔案


    ''' </summary>


    ''' <param name="SourceFiles">要壓縮的檔案(完整路徑)</param>


    ''' <param name="TargetFile">要產生的Zip檔案(完整路徑檔名)</param>


    ''' <returns></returns>


    Public Sub ZipFile(ByVal SourceFile As String, ByVal TargetFile As String)


        Me.ZipFile(SourceFile, TargetFile, "", True)


    End Sub


 


    ''' <summary>


    ''' 解壓縮


    ''' </summary>


    ''' <param name="SourceFile">要解壓縮的Zip檔案(完整路徑檔名) </param>


    ''' <param name="TargetDir">解壓縮後存放的資料夾路徑(完整路徑) </param>


    ''' <param name="Password">密碼</param>


    Public Sub ExtractZip(ByVal SourceFile As String, ByVal TargetDir As String, ByVal Password As String)


        Dim oZip As New ICSharpCode.SharpZipLib.Zip.FastZip()


        Try


            '判斷要產生的ZIP檔案是否存在


            If File.Exists(SourceFile) = False Then


                Throw New Exception("要解壓縮的檔案【" & SourceFile & "】不存在,無法執行")


            End If


            If Password <> "" Then


                oZip.Password = Password


            End If


            oZip.ExtractZip(SourceFile, TargetDir, "")


        Catch


            Throw


        End Try


    End Sub


 


    ''' <summary>


    ''' 解壓縮


    ''' </summary>


    ''' <param name="SourceFile">要解壓縮的Zip檔案(完整路徑檔名) </param>


    ''' <param name="TargetDir">解壓縮後存放的資料夾路徑(完整路徑) </param>


    Public Sub ExtractZip(ByVal SourceFile As String, ByVal TargetDir As String)


        Me.ExtractZip(SourceFile, TargetDir, "")


    End Sub


 


End Class


 


 





(繼續閱讀...)
文章標籤

M 發表在 痞客邦 留言(0) 人氣(1,786)

  • 個人分類:VB.Net
▲top
  • 10月 08 週二 201310:56
  • [VB.Net][全型轉半型不含中文字]





Imports System.Text


 


'全型轉半型


Public Function ToNchr(ByRef data As String) As String


  Dim sb As New StringBuilder


  Dim ascii As Integer = 0


 


  For Each c As Char In data.Replace("〔", "[").Replace("〕", "]").Replace("'", "'").ToCharArray()


    ascii = System.Convert.ToInt32(c)


    If ascii = 12288 Then


      sb.Append(System.Convert.ToChar(32))


    Else


      If ascii > 65280 And ascii < 65375 Then


        sb.Append(System.Convert.ToChar(ascii - 65248))


      Else


        sb.Append(System.Convert.ToChar(ascii))


      End If


    End If


  Next


 


  Return sb.ToString


End Function





(繼續閱讀...)
文章標籤

M 發表在 痞客邦 留言(0) 人氣(120)

  • 個人分類:VB.Net
▲top
  • 10月 08 週二 201310:54
  • [VB.Net][檔案Anis轉成Unicode格式]





Imports System.IO


Imports System.Text


 


'檔案Anis轉成Unicode格式


Dim reader1 As New StreamReader("D:\TEST.DAT", Encoding.GetEncoding(0))


Dim writer1 As New StreamWriter("D:\TEST_Un.TXT", True, Encoding.Unicode)


 


writer1.Write(reader1.ReadToEnd)


writer1.Flush()


writer1.Close()


reader1.Close()





(繼續閱讀...)
文章標籤

M 發表在 痞客邦 留言(0) 人氣(102)

  • 個人分類:VB.Net
▲top
  • 10月 08 週二 201310:53
  • [VB.Net][使用StreamWriter匯出文字檔]





Imports System.IO


Imports System.Text


 


'StreamWriter匯出文字檔


Dim sL_Path As String = "D:\AAA.csv"


Dim sw As StreamWriter = New StreamWriter(sL_Path, True, Encoding.Unicode)


If File.Exists(sL_Path) Then


  File.Delete(sL_Path)


End If


 


sw.WriteLine("開始")


sw.WriteLine("內容1")


sw.WriteLine("內容2")


sw.WriteLine("結束")


 


sw.Close()





(繼續閱讀...)
文章標籤

M 發表在 痞客邦 留言(0) 人氣(1,655)

  • 個人分類:VB.Net
▲top
12»

熱門文章

  • (1,005)[VB.Net] NPOI 元件產生Execl
  • (13,830)[VBA]Access巨集指令
  • (819)[VB.Net][GridView上下鍵](按鍵盤上的下,跳到下一行…)
  • (8,554)[VB.Net][DataTable、DataView、DataSet與DataRow的互轉]
  • (1,786)[VB.Net][使用ICSharpCode.SharpZipLib.dll元件處理壓縮]

文章分類

  • 其他 (1)
  • 裝潢設計 (1)
  • MS-Dos (1)
  • VBA(Access) (6)
  • T-SQL (5)
  • Android (3)
  • VB.Net (16)
  • 未分類文章 (1)

最新文章

  • [T-SQL]不常用SQL語法
  • [T-SQL]產生Table描述語法
  • Excel公式實用範例
  • [T-SQL]SQL 字串分割 回傳Table
  • [VB.Net][使用使用CDONTS.NewMail 發送Mail]
  • [其他][ASCII字碼表]
  • [VB.Net][連線錯誤訊息]
  • [VBA][Access與SQL Server的語法差異]
  • [VBA][Access 97讀取INI檔案]
  • [VBA][Access 97找尋目前檔案路徑]

文章精選

文章搜尋

參觀人氣

  • 本日人氣:
  • 累積人氣: