2014年6月3日 星期二

VB.net 字串格式 Format

Format是VB.Net中很好用,不需死記參數,很人性化的格式化Function,舉例:
123456789 (三位一撇千分位)
Format(123456789, "###,###")    OutPut ; 123,456,789
0.2666666 (小數點後兩位,四捨五入,並加上%)
Format(0.2666666,"0.00%")         OutPut  : 26.67%
 千分位,小數點捨去
Format(Val(strValue.ToString), "###,##0")


2014年6月2日 星期一

VB.net 一次控制全部元件(TextBox等)

        Dim Command1() As TextBox = _
            {tbPanel1, tbPanel2, tbPanel3, tbPanel4, tbPanel5, tbPanel6, tbPanel7, tbPanel8, tbPanel9, tbPanel10}


            If ComboBox9.SelectedIndex >= i Then
                Command1(i).Visible = True
            Else

VB.net 拆字串 分割字串 切字串

text.Split(",")



Dim strMember1 As String() = strTemp.Split(vbCrLf)    '分行切割

Dim strMember2 As String() = strMember1(intSelected).Split(",")

        strMember3(intSelected) = strMember2(0).Trim()   '去空白 姓名
        TextBox1.Text = strMember3(intSelected)

VB.net 去空白 去換行

.Trim()

strMember3(intSelected) = strMember2(0).Trim()   '去空白 姓名

VB.net 換行符號(vbcrlf)

換行符號: vbcrlf

Tab: vbTab

網頁自動登入登出程式

http://tomshare.idv.tw/article/vb-net_auto_login_logout/


VB打開網頁超連結Url

VB創建超連結 打開指定網站的幾種方法

方法一:
Shell "Rundll32.exe url.dll, FileProtocolHandler HTTP://tw.yahoo.com", vbNormalFocus

方法二:
Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE " & Text1.Text, vbMaximizedFocusEnd Sub

方法三:
Shell ("explorer HTTP://tw.yahoo.com "), vbNormalFocus

方法四:
Public Declare Function ShellExecute Lib "shell32.dll " Alias "ShellExecuteA " (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

ShellExecute 0, " ", " HTTP://tw.yahoo.com", " ", " ", 5