c#与最牛vb算法比拼 by Error
文章来源: http://www.zoesan.com By Error 302777528转载请注明出处
以上vb用到指针技术查找字符串与c#一般的.indexof()查找相比较,明显看出谁快谁慢。
VB:
Option Explicit
'指针方法操作字符串
'Copy一个字符串到缓存中
Public Declare Function GetTickCount Lib "kernel32" () As Long
Public Declare Function lstrcpy Lib "Kernel32.dll" Alias "lstrcpyW" (lpszString1 As Any, lpszString2 As Any) As Long
'通过指针获取字符串的长度
Public Declare Function lstrlen Lib "Kernel32.dll" Alias "lstrlenW" (ByVal lpszString As Long) As Long
Public Function FindTextInStr(ByVal OriStr As String, ByVal strText As String) As Long
Dim Buff() As Byte '声明一个Byte数组
Dim Pointer As Long '声明一个变量,用于存储指针
Pointer = StrPtr("Love")
ReDim Buff(0 To lstrlen(Pointer) * 2 - 1) As Byte '分配缓存大小,由于得到的是Unicode,所以乘以2
lstrcpy Buff(0), ByVal Pointer '复制到缓存Buff中
' Me.Caption = InStr(1, Buff, StrConv("o", vbfromUnicode))
FindTextInStr = InStr(OriStr, StrConv(strText, vbfromUnicode)) '查找子字符串位置
' Debug.Print Buff '显示到text1中
End Function
Private Sub Command1_Click()
Dim sTime As Long
sTime = GetTickCount
For i = 1 To 10000
Call comPareTime
Next
sTime = GetTickCount - sTime
Label1.Caption = "查找10000次粤ICP备05004654号花费" & sTime & "ms"
End Sub
Sub comPareTime()
Dim i1 As Long
i1 = FindTextInStr(RichTextBox1.Text, "粤")
End Sub
'''''''''''''''''''''''''''''''''''''''''''
C#代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Configuration;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebContro
相关文档:
接着外挂教程 VB 从零开始编外挂
需要VBAPI函数:
FindWindow←寻找窗口列表中第一个符合指定条件的顶级窗口
GetWindowThreadProcessId←获取与指定窗口关联在一起的一个进程和线程标识符
--------------------------------------------------------------------------------------------------------------- ......
这几天在设计阅读其中用到了很多好的技术,,让我们在设计软件的时候方便,,快捷,,美观.也是我们经常用到的一些控件.
所以在这里我会陆续把他分享出来.
这里是在窗体中改变窗体的大小.窗体内部所以控件的大小同比例的改变的一个程序
这些是在标准模块中
'定义 FormOldWidth, FormOldHeight 为全局变量,这样其他模块才能 ......
-----------------------------.cs类文件中
当前项目的物理路径嘛:
strPath = this.Server.MapPath(Request.PhysicalApplicationPath);
你要说明什么“类文件”。任何PAGE、CONTROL代码也是在类 ......
1、用MySQLDriverCS连接MySQL数据库
先下载和安装MySQLDriverCS,地址:http://sourceforge.net/projects/mysqldrivercs/在安装文件夹下面找到MySQLDriver.dll,然后将MySQLDriver.dll添加引用到项目中注:我下载的是版本是 MySQLDriverCS-n-EasyQueryTools-4.0.1-DotNet2.0.exe using System;using System.Collectio ......
C#代码与javaScript函数的相互调用
问:
1.如何在JavaScript访问C#函数?
2.如何在JavaScript访问C#变量?
3.如何在C#中访问JavaScript的已有变量?
4.如何在C#中访问JavaScript函数?
问题1答案如下:
javaScript函数中执行C#代码中的函数:
方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click中 ......