189 8069 5689

包含vb.net,exp的词条

VB.net中正则表达式实例

在所给代码基础上仅作修改.

在渝北等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都做网站、网站制作 网站设计制作按需网站开发,公司网站建设,企业网站建设,成都品牌网站建设,营销型网站建设,外贸网站制作,渝北网站建设费用合理。

首先导入命名空间

Imports System.Text.RegularExpressions

然后:

Function geta(ByVal Str)

Dim re As New Regex("a(.+?)href=""*([^\s]+?)""*(\s|)")

Dim Contents As MatchCollection = re.Matches(Str)

Dim links As String = Nothing

For Each Match In Contents ' 遍历匹配集合。

links = links + Match.SubMatches(1) + "|"

Next

geta = Mid(links, 1, Len(links) - 1)

geta = Replace(geta, "'", "")

re = Nothing

End Function

利用VB.NET实现导出DataTable数据到excel中,各位大侠帮帮忙,最好有源码,谢谢,江湖救急

刚好写了个Helper类,你试验一下DataTable2Exce(这个方法代码如下:

Imports System.IO

Imports System.Data

Imports System.Data.OleDb

Public MustInherit Class ExcelHelper

Private Shared Function buildConnStr(excelFilePath As String) As String

Dim excelFileInfo As New System.IO.FileInfo(excelFilePath)

Dim constr As String

If excelFileInfo.Extension = ".xlsx" Then

constr = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0 Xml;HDR=YES;IMEX=1'", excelFilePath)

Else

constr = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'", excelFilePath)

End If

Return constr

End Function

'将datatable导入到excel

Public Shared Function DataTable2Excel(dt As DataTable, excelFilePath As String) As Boolean

If File.Exists(excelFilePath) Then

Throw New Exception("该文件已经存在!")

End If

If dt.TableName.Trim.Length = 0 Or dt.TableName.ToLower = "table" Then

dt.TableName = "Sheet1"

End If

Dim colCount As Integer = dt.Columns.Count

Dim pa(colCount - 1) As OleDb.OleDbParameter

Dim tableStructStr As String = "Create Table " dt.TableName "("

Dim connString As String = buildConnStr(excelFilePath)

Dim objconn As New OleDbConnection(connString)

Dim objcmd As New OleDbCommand

objcmd.Connection = objconn

Dim dataTypeList As New ArrayList

dataTypeList.Add("System.Decimal")

dataTypeList.Add("System.Double")

dataTypeList.Add("System.Int16")

dataTypeList.Add("System.Int32")

dataTypeList.Add("System.Int64")

dataTypeList.Add("System.Single")

Dim i As Integer = 0

For Each col As DataColumn In dt.Columns

If dataTypeList.IndexOf(col.GetType.ToString) 0 Then

pa(i) = New OleDbParameter("@" col.ColumnName, OleDbType.Double)

objcmd.Parameters.Add(pa(i))

If i + 1 = colCount Then

tableStructStr += col.ColumnName + " double)"

Else

tableStructStr += col.ColumnName + " double,"

End If

Else

pa(i) = New OleDbParameter("@" col.ColumnName, OleDbType.VarChar)

objcmd.Parameters.Add(pa(i))

If i + 1 = colCount Then

tableStructStr += col.ColumnName + " VarChar)"

Else

tableStructStr += col.ColumnName + " VarChar,"

End If

End If

i += 1

Next

Try

objcmd.CommandText = tableStructStr

If objconn.State = ConnectionState.Closed Then objconn.Open()

objcmd.ExecuteNonQuery()

Catch ex As Exception

Throw ex

End Try

Dim InsertSql_1 As String = "Insert into " + dt.TableName + " ("

Dim InsertSql_2 As String = " Values ("

Dim InsertSql As String = ""

For colID As Integer = 0 To colCount - 1 Step 1

If colID + 1 = colCount Then

InsertSql_1 += dt.Columns(colID).ColumnName ")"

InsertSql_2 += "@" + dt.Columns(colID).ColumnName + ")"

Else

InsertSql_1 += dt.Columns(colID).ColumnName + ","

InsertSql_2 += "@" + dt.Columns(colID).ColumnName + ","

End If

Next

InsertSql = InsertSql_1 + InsertSql_2

For rowID As Integer = 0 To dt.Rows.Count - 1 Step 1

For colID = 0 To dt.Columns.Count - 1

If pa(colID).DbType = DbType.Double And dt.Rows(rowID)(colID).ToString.Trim = "" Then

pa(colID).Value = 0

Else

pa(colID).Value = dt.Rows(rowID)(colID).ToString.Trim

End If

Next

Try

objcmd.CommandText = InsertSql

objcmd.ExecuteNonQuery()

Catch ex As Exception

Throw ex

End Try

Next

Try

If objconn.State = ConnectionState.Open Then objconn.Close()

Catch exp As Exception

Throw exp

End Try

Return True

End Function

' 获取Excel文件数据表列表Sheets

Public Shared Function GetExcelTables(ExcelFileName As String) As ArrayList

'Dim sheets As New List(Of String)

'conn.Open()

'Dim dt As DataTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)

'For Each r In dt.Rows

' sheets.Add(r("TABLE_NAME"))

'Next

'conn.Close()

'Return sheets

Dim dt As DataTable

If Not File.Exists(ExcelFileName) Then

Throw New Exception("指定的Excel文件不存在")

Return Nothing

End If

Dim tableList As New ArrayList

Using conn As OleDbConnection = New OleDbConnection(buildConnStr(ExcelFileName))

Try

conn.Open()

dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"})

Catch ex As Exception

Throw ex

End Try

For i As Integer = 0 To dt.Rows.Count - 1

Dim tableName As String = dt.Rows(i)(2).ToString.Trim.TrimEnd("$")

If tableList.IndexOf(tableName) 0 Then tableList.Add(tableName)

Next

End Using

Return tableList

End Function

'将Excel文件导出至DataTable(第一行作为表头)

Public Shared Function InputFromExcel(ExcelFileName As String, TableName As String) As DataTable

If Not File.Exists(ExcelFileName) Then

Throw New Exception("指定的Excel文件不存在")

End If

Dim tableList As ArrayList = GetExcelTables(ExcelFileName)

If tableList.IndexOf(TableName) 0 Then

TableName = tableList(0).ToString.Trim

End If

Dim dt As New DataTable

Dim conn As New OleDbConnection(buildConnStr(ExcelFileName))

Dim cmd As New OleDbCommand("select * from [" TableName "$]", conn) '调试是否需要$

Dim adapter As New OleDbDataAdapter(cmd)

Try

If conn.State = ConnectionState.Closed Then conn.Open()

adapter.Fill(dt)

Catch ex As Exception

Throw ex

Finally

If conn.State = ConnectionState.Open Then conn.Close()

End Try

Return dt

End Function

'查询excel文件中的一个数据

Public Shared Function ReadOneDataFromExcel(ExcelFileName As String, TableName As String, sql As String) As Object

If Not File.Exists(ExcelFileName) Then

Throw New Exception("指定的Excel文件不存在")

End If

Dim tableList As ArrayList = GetExcelTables(ExcelFileName)

If tableList.IndexOf(TableName) 0 Then

TableName = tableList(0).ToString.Trim

End If

Dim dt As New DataTable

Dim conn As New OleDbConnection(buildConnStr(ExcelFileName))

Dim cmd As New OleDbCommand(sql, conn) '调试是否需要$

Dim ret As Object

Try

If conn.State = ConnectionState.Closed Then conn.Open()

ret = cmd.ExecuteScalar()

Catch ex As Exception

Throw ex

Finally

If conn.State = ConnectionState.Open Then conn.Close()

End Try

Return ret

End Function

'获取Excel文件指定数据表的数据列表columnNames

Public Shared Function GetExcelTableColumns(ExcelFileName As String, TableName As String) As ArrayList

Dim dt As DataTable

If Not File.Exists(ExcelFileName) Then

Throw New Exception("指定的Excel文件不存在")

Return Nothing

End If

Dim ColList As New ArrayList

Using conn As OleDbConnection = New OleDbConnection(buildConnStr(ExcelFileName))

Try

conn.Open()

dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, New Object() {Nothing, Nothing, TableName, Nothing})

Catch ex As Exception

Throw ex

End Try

For i As Integer = 0 To dt.Rows.Count - 1

Dim ColName = dt.Rows(i)("Column_Name").ToString().Trim()

ColList.Add(ColName)

Next

End Using

Return ColList

End Function

End Class

用VB.net打包后的软件,如何支持覆盖安装呢?

,如果客户终端非常多的时候,这就会是一项很麻烦的工作,一方面要安排我们的应用程序,另一方面要安装Oracle客户端,而且还要对Oracle客户端进行NET EASY配置,真是不胜其烦。

为此我研究了很久,现在终于做到了可以把Oracle客户端和应用程序一起打包,又自己用程序来配置NET EASY,刚好前两天有两个小弟问我如何把客户端打包和用程序配置NET EASY的问题,我今天就在这里说一下。

由于时间问题,今天就只能讲一下客户端打包的问题,另一个问题我会在下一篇给大家讲一下。

1、打包要知道的问题:

A、要打包哪些文件。

B、如何修改注册表。

C、如何设置环境变量。

D、打包使用哪些工具。

2、打包要使用的文件:

我们先找一个装有Oracle的机器,把以下的文件打包。为了保证Oracle能正常访问,我们需要保持原目录结构不变。

A、$ORACLE_HOMEBIN下边所有DLL,IMP.EXE,EXP.EXE,SQLPLUS.EXE,SQLPLUSW.EXE。($ORACLE_HOME指的是ORACLE的主目录,比如D:ORACLEORA8I)。

B、$ORACLE_HOMEnetwork目录下的三个目录:Admin、mesg、tnsapi,把它们全部打包。

C、$ORACLE_HOMEocommonnls目录。

D、$ORACLE_HOMEoracoremesg目录。

E、$ORACLE_HOMEsqlplus下的两个目录:admin、mesg。

3、如何修改注册表:

为不麻烦,我们可以把这个装有Oracle的机器的注册表里边Oracle信息照搬过来。全部照抄。

4、如何设置环境变量:

设置环境变量,我们要在PATH前边加上$ORACLE_HOMEBIN;

5、使用哪些打包工具:

我个人比较喜欢的工具是WiseInstaller,它的功能很强大,能导入整个文件目录(我感觉这一点比Install shilled要好)、导入注册表、也可以设置环境变量,以及设置NT服务等等(我好象是给它做广告似的)。

我们现在就可以使用它来做我们的客户端了。

第一步,先把我说的这些文件目录全部导入到我们的安装工程中去。

第二步,找到设置注册表选项,导入注册表中HKEY_LOCAL_MACHINESOFTWAREORACLE下边所有的注册表值。

第三步,找到环境变量设置选项,在它的PATH那里加上$ORACLE_HOMEBIN。这里的$ORACLE_HOME用来代替。

做完这一切,编译,发布,完成。

6、如何用手工来修改NET EASY:

现在假设我们已经做完了这个安装包,并且把它安装到了我们的电脑上边,那么,在开始菜单上是没有ORACLE这个选项的,如何设置Oracle NET EASY呢?

我们现在暂时可以这样做:

打开我们的Oracle客户端的安装目录,找到NETWORKADMIN子目录下边的tnsnames.ora这个文件,直接对它进行编辑就行了。

比如,我们现在想配置一个叫做NTSERVER的服务名,我们就可以这样写:

NTSERVER =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 机器名)(PORT = 端口号))

)

(CONNECT_DATA =

(SERVICE_NAME = 全局数据库名)

)

)

然后,直接把它加到tnsnames.ora这个文件的后边就行了。

如果NTSERVER这个服务名已经存在的话,我们可以直接修改它的机器名、端口号和全局数据库名就可以了。

在vb中。如何进行三角函数的程序代码编写

有几个地方要注意:

1、VB中的三角函数的角度全部是用弧度制表示的,如果是度数的话,应先乘以180再除以π转成弧度,再用函数计算结果。

2、VB中直接支持的三角函数有:Sin()、Cos()、Tan(),如果涉及到其它三角函数,可以从下面列出的代码中自己选择相应的函数:

Function

Sec(X)

As

Double

'正割

Sec

=

1

/

Cos(Angle)

End

Function

Function

Csc(X)

As

Double

'余割

Csc

=

1

/

Sin(Angle)

End

Function

Function

Cot(X)

As

Double

'余切

Cot

=

1

/

Tan(Angle)

End

Function

Function

ArcSin(X)

As

Double

'反正弦

ArcSin

=

Atn(X

/

Sqr(-X

*

X

+

1))

End

Function

Function

ArcCos(X)

As

Double

'反余弦

ArcCos

=

Atn(-X

/

Sqr(-X

*

X

+

1))

+

2

*

Atn(1)

End

Function

Function

ArcSec(X)

As

Double

'反正割

ArcSec

=

Atn(X

/

Sqr(X

*

X

-

1))

+

Sgn((X)

-

1)

*

(2

*

Atn(1))

End

Function

Function

ArcCsc(X)

As

Double

'反余割

ArcCsc

=

Atn(X

/

Sqr(X

*

X

-

1))

+

(Sgn(X)

-

1)

*

(2

*

Atn(1))

End

Function

Function

ArcCot(X)

As

Double

'反余切

ArcCot

=

Atn(X)

+

2

*

Atn(1)

End

Function

Function

HSin(X)

As

Double

'双曲正弦

HSin

=

(Exp(X)

-

Exp(-X))

/

2

End

Function

Function

HCos(X)

As

Double

'双曲余弦

HCos

=

(Exp(X)

+

Exp(-X))

/

2

End

Function

Function

HTan(X)

As

Double

'双曲正切

HTan

=

(Exp(X)

-

Exp(-X))

/

(Exp(X)

+

Exp(-X))

End

Function

Function

HSec(X)

As

Double

'双曲正割

HSec

=

2

/

(Exp(X)

+

Exp(-X))

End

Function

Function

HCsc(X)

As

Double

'双曲余割

HCsc

=

2

/

(Exp(X)

-

Exp(-X))

End

Function

Function

HCot(X)

As

Double

'双曲余切

HCot

=

(Exp(X)

+

Exp(-X))

/

(Exp(X)

-

Exp(-X))

End

Function

Function

HArcsin(X)

As

Double

'反双曲正弦

HArcsin

=

Log(X

+

Sqr(X

*

X

+

1))

End

Function

Function

HArccos(X)

As

Double

'反双曲余弦

HArccos

=

Log(X

+

Sqr(X

*

X

-

1))

End

Function

Function

HArctan(X)

As

Double

'反双曲正切

HArctan

=

Log((1

+

X)

/

(1

-

X))

/

2

End

Function

Function

HArcsec(X)

As

Double

'反双曲正割

HArcsec

=

Log((Sqr(-X

*

X

+

1)

+

1)

/

X)

End

Function

Function

HArccsc(X)

As

Double

'反双曲余割

HArccsc

=

Log((Sgn(X)

*

Sqr(X

*

X

+

1)

+

1)

/

X)

End

Function

Function

HArccot(X)

As

Double

'反双曲余切

HArccot

=

Log((X

+

1)

/

(X

-

1))

/

2

End

Function


网站标题:包含vb.net,exp的词条
网址分享:http://jkwzsj.com/article/hcecis.html

其他资讯