1.字符串分割                                                                                                                                                                                                                                    

        字符串取左                                                              Microsoft.VisualBasic.Left(row.Item(0).ToString, 2)

        取得指定字符前面内容                                       TextBox2.Text = TextBox1.Text.Split("#")(0)

        字符串中指定文字位置查询                              instr(st,“er”)

                                                          返回待判断字符串在原字符串中第一次出现的位置,如果不包含的话返回0

                                                                                                                                                                                                                                         

2.vb.net多行注释快捷键

Ctrl+k,Ctrl+c    注释

Ctrl+k,Ctrl+u    取消注释

Ctrl+k,Ctrl+f    格式化(自动对齐)选定代码段

                                                                                                                                                                                                                                         

3.String类型转换成int

         Dim year As Integer = Convert.ToInt32(Microsoft.VisualBasic.Left(salesDate, 4))

                                                                                                                                                                                                                                         

4.combox相关

         combox内容list循环

         For k = 0 To cb_table_list.Items.Count - 1 Step 1

                     '取得第k项内容

                     dataType = cb_table_list.GetItemText(cb_table_list.Items.Item(k))

                                                                                                                                                                                                                                         

5.vb.net报错:从字符串“aa”到类型“Double”的转换无效”的错误

程序发现程序是错在一个数字型的变量和一个字符型的变量的连接上,现简化如下:

    Dim iTemp As Integer = 3                                                                                                                                                                                                                                         

    Dim strTemp As String = "aa"                                                                                                                                                                                                                                 

    Response.Write(strTemp + iTemp)

vb.net中有连接运算符"&"和"+"

 

+  加连接符 如果两个操作数为String就把这两个操作数连接成一个字符串,否则按加号处理。

&  连接符  将操作数据强行转换成String再进行连接运算。

 

结论:             要用&来连接

 

6.字符串分割 

'定义数组,记录字符串分割的结果
                                Dim strArr() As String
                                Dim index As Integer
                                '毫升数
                                Dim MLCount As Double = 0
                                '毫克数
                                Dim MGCount As Double = 0
                                '克数
                                Dim GCount As Double = 0

                                strArr = Split(row.Item(1).ToString.Trim, Constant.SPACE_1)
                                For index = strArr.Length - 1 To 0 Step -1
                                    '包含G,且不包含"MG"(因为该项内容中存在"VIDISIC EYE GEL 1MG/G 10G"这样有多部分含有MG/G的情况)
                                    If InStr(strArr(index), Constant.UNIT_G) <> 0 _
                                        And InStr(strArr(index), Constant.UNIT_MG) = 0 Then
                                        '取得克数
                                        GCount = Microsoft.VisualBasic.Left(strArr(index), InStr(strArr(index), Constant.UNIT_G) - 1)
                                        Exit For
                                    End If

                                    '包含ML,且不包含"%"(因为该项内容中存在"HIALID EYE DRP 0.1%/ML 5ML 10"这样有多部分含有ML的情况)
                                    If InStr(strArr(index), Constant.UNIT_ML) <> 0 _
                                        And InStr(strArr(index), "%") = 0 Then
                                        '取得毫升数
                                        MLCount = Microsoft.VisualBasic.Left(strArr(index), InStr(strArr(index), Constant.UNIT_ML) - 1)
                                        Exit For
                                    End If

                                    '包含MG,且不包含"/"(因为该项内容中存在"VIDISIC EYE GEL 1MG/G 10G"这样有多部分含有MG/G的情况)
                                    If InStr(strArr(index), Constant.UNIT_MG) <> 0 _
                                        And InStr(strArr(index), "/") = 0 Then
                                        '取得毫克数
                                        MGCount = Microsoft.VisualBasic.Left(strArr(index), InStr(strArr(index), Constant.UNIT_MG) - 1)
                                        Exit For
                                    End If

                                Next

 

7.链接Excel的database设定:

        参数HDR的值:                                                                                                                                                                                                                          

         HDR=Yes,这代表第一行是标题,不做为数据使用,如果用HDR=NO,则表示第一行不是标题,做为数据来使用。系统默认的是YES                                                                                                                                                                                                                             

         IMEX ( IMport EXport mode )设置

        当IMEX=0时为“汇出模式”,这个模式开启的Excel档案只能用来做“写入”用途。

        当IMEX=1时为“汇入模式”,这个模式开启的Excel档案只能用来做“读取”用途。

        当IMEX=2时为“连結模式”,这个模式开启的Excel档案可同时支援“读取”与“写入”用途。

                                                                                                                                                                                                                                         

8.textbox中内容回车换行                                                                                                                                                                                                                                        

         txtResult.Text = "压缩成功!!" & Chr(13) & Chr(10)

 

9.textbox中内容追加及即时显示

         txtResult.AppendText("报表'Tears Monthly Data REGULAR.xlsx'生成完毕" & Chr(13) & Chr(10))

         txtResult.Show()