1、建立一个txt文档
创新互联建站是一家从事企业网站建设、成都网站制作、成都网站设计、行业门户网站建设、网页设计制作的专业网络公司,拥有经验丰富的网站建设工程师和网页设计人员,具备各种规模与类型网站建设的实力,在网站建设领域树立了自己独特的设计风格。自公司成立以来曾独立设计制作的站点上千家。
2、改扩展名为*.udl
3、双击运行-》提供程序SQL Native Client
4、连接-》数据源为当前sql 服务器
5、设置登陆方式
6、选择连接的数据库
7、测试连接
8、关闭
9、用记事本打开
10、把记事本里的内容 由provider···开始复制到constring
rem
是注释的意思``和
'
一样````不过rem必须另起一行
而
'
在每句后边写也成~~
首先是C的DLL(我的项目叫ConsoleApplication2.dll):
#include Windows.h
// 导出Test函数,供外部使用
extern "C" __declspec(dllexport) BSTR __cdecl Test(LPSTR p);
BOOL WINAPI DllMain(
HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH: break;
case DLL_THREAD_ATTACH: break;
case DLL_THREAD_DETACH: break;
case DLL_PROCESS_DETACH: break;
}
return TRUE;
}
BSTR __cdecl Test(LPSTR p)
{
p[0] = 'X';
return SysAllocString((BSTR)p);
}
然后是VB.Net项目:
Imports System.Runtime.InteropServices
Imports System.Text
Module Module1
REM 生成的是ConsoleApplication2.dll,名字与C里面相同
DllImport("ConsoleApplication2.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.Cdecl)
Public Function Test(MarshalAs(UnmanagedType.LPTStr) ByVal str As StringBuilder) As MarshalAs(UnmanagedType.BStr) String
End Function
Sub Main()
Dim str As StringBuilder = New StringBuilder("Hello")
Dim rstr As String = Test(str)
Console.WriteLine(rstr)
Console.ReadKey()
End Sub
End Module
运行结果:
Imports System.Text.RegularExpressions
Public Class Form1
Public Function MadeRegexArray(ByVal strText As String, ByVal strRegx As String, ByVal rexOpt As RegexOptions, ByVal Groups As Integer) As String()
REM 正则结果直接以字符串组形式返回
REM strHtml待搜索的字符串
REM strRegx正则表达式
REM rexOpt正则选项
On Error Resume Next
Return MadeMatchString(MadeRegexMatch(strText, strRegx, rexOpt), Groups)
End Function
Public Function MadeMatchString(ByVal mc As MatchCollection, ByVal Groups As Integer) As String()
REM 把MatchCollection以字符串组形式保存
REM mc正则匹配的集合
REM 返回字符串组
On Error Resume Next
Dim strRegCode(mc.Count) As String
For i As Integer = 0 To mc.Count - 1
strRegCode(i) = mc(i).Groups(Groups).Value
Next i
Return strRegCode
End Function
Public Function MadeRegexMatch(ByVal strText As String, ByVal strRegex As String, ByVal rexOpt As RegexOptions) As MatchCollection
REM 获取正则表达式匹配的集合
REM strHtml待正则的字符串
REM strRegex正则表达式
REM rexOpt正则选项
REM 返回 MatchCollection 类型集合
On Error Resume Next
Dim rex As Regex = New Regex(strRegex, rexOpt)
Return rex.Matches(strText)
End Function
Public Function MadeRegexReplace(ByVal sText As String, ByVal sRegex As String, ByVal sReplace As String) As String
REM 正则表达式文本替换
REM sText原文本
REM sRegex表达式
REM sReplace替换文本
On Error Resume Next
Dim rex As Regex = New Regex(sRegex, RegexOptions.IgnoreCase)
Return rex.Replace(sText, sReplace)
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error Resume Next
Dim sRegex As String = "([\s\S]*?)"
Dim aTable() As String = MadeRegexArray(TextBox1.Text, sRegex, RegexOptions.IgnoreCase, 1)
For i As Integer = 0 To aTable.Length - 1
TextBox2.Text = TextBox2.Text aTable(i)
Next i
End Sub
End Class
如图:
代码注释用的,增加程序的可读性,在实际程序编译中不起作用,功能与单引号(')的功能一样rem 这是代码注释'这是代码注释
REM
后面可以加任何内容,该行都是程序的注释
比如
REM
12345
REM
计算器
Calculator
REM
Hello
World!
随便怎么写
可以认为rem相当于'
但是只能用于句首,不可以用在某一语句之后,必须另起一行