易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : vb

VB中删除数组重复元素

Option Explicit
Function Delete3(Arr As Variant) As Variant
Dim i As Integer
For i = LBound(Arr) To UBound(Arr)
If i > UBound(Arr) Then Exit For
If Arr(i) = 3 Then
Do
Dim j As Integer
For j = i To UBound(Arr) - 1
Arr(j) = Arr(j + 1)
Next j
If LBound(Arr) = UBound(Arr) Then
Delete3 = Empty
Exit Function
End If
ReDim Preserve Arr(LBound(Arr) To UBound(Arr) - 1)
If i > UBound(Arr) Then Exit For
Loop While Arr(i) = 3
End If
Next i
Delete3 = Arr
End Function
Sub Test()
Delete3 (Array(3, 3, 3, 3, 1, 3, 7, 3, 3, 3, 9, 3, 3))
Delete3 (Array(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3))
Delete3 (Array(1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3))
Delete3 (Array(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1))
End Sub
......

vb Active 控件 集合类 问题

引言:
         做一个控件, 用于 数据采样如示波器, 可以添加,删除曲线, 设置曲线的相关属性: 线型,颜色,等...
过程:
         先创建 线 类,  在用户控件里实现 线 对象创建,  并声明一个 集合, 用于 存放建立的线对象.
问题:
         在应用程序中, 无法显示 集合中对象的 属性. 如:  usercontrol1. lines(1).???
         其中 lines 是个对象集合.
         而且 在应用程序中添加线, 直接操作集合的方法也不好, usercontrol1.lines.Add  
    (item,key,before,after)
       其实我想实现是个类似 ToolBar 的功能, Toolbar1.buttons(0).属性 ,
  Toolbar1.buttons.Add( index,key ,...)
      
  这样用户交互直观,安全.
解决:
   期待高手给点建议,
   看MSDN 似乎可以 声明 安全类集合, 这样就可以实现 用户程序里显示属性, 但Add ......

Developer Support Languages VC++, C# and VB.NET


Welcome to Microsoft Developer Support, Languages team blog! You will find a lot of language related troubleshooting resources here.
Troubleshooting PInvoke Related Issues 
I am back with some more PInvoke Stuff.  Recently I was working on a PInvoke issue which I found interesting. 
I have a C++ dll which has a function whose signature is
int TestFunc(IN_STRUCT in_Params, RET_STRUCT * pret_Par). 
I wanted to call this function from C#.  Function has two arguments.  First argument is input structure which will be filled from C# code and passed to C++ code.  Second argument is output structure which is filled in C++ code and output to C# code.
 Here are the C struct definitions and a function that needs to be marshaled
#include "stdafx.h"
#include <stdio.h>
#include "Objbase.h"
#include <malloc.h>
 
 
typedef struct IN_STRUCT
{
    &nbs ......

Developer Support Languages VC++, C# and VB.NET


Welcome to Microsoft Developer Support, Languages team blog! You will find a lot of language related troubleshooting resources here.
Troubleshooting PInvoke Related Issues 
I am back with some more PInvoke Stuff.  Recently I was working on a PInvoke issue which I found interesting. 
I have a C++ dll which has a function whose signature is
int TestFunc(IN_STRUCT in_Params, RET_STRUCT * pret_Par). 
I wanted to call this function from C#.  Function has two arguments.  First argument is input structure which will be filled from C# code and passed to C++ code.  Second argument is output structure which is filled in C++ code and output to C# code.
 Here are the C struct definitions and a function that needs to be marshaled
#include "stdafx.h"
#include <stdio.h>
#include "Objbase.h"
#include <malloc.h>
 
 
typedef struct IN_STRUCT
{
    &nbs ......

Developer Support Languages VC++, C# and VB.NET


Welcome to Microsoft Developer Support, Languages team blog! You will find a lot of language related troubleshooting resources here.
Troubleshooting PInvoke Related Issues 
I am back with some more PInvoke Stuff.  Recently I was working on a PInvoke issue which I found interesting. 
I have a C++ dll which has a function whose signature is
int TestFunc(IN_STRUCT in_Params, RET_STRUCT * pret_Par). 
I wanted to call this function from C#.  Function has two arguments.  First argument is input structure which will be filled from C# code and passed to C++ code.  Second argument is output structure which is filled in C++ code and output to C# code.
 Here are the C struct definitions and a function that needs to be marshaled
#include "stdafx.h"
#include <stdio.h>
#include "Objbase.h"
#include <malloc.h>
 
 
typedef struct IN_STRUCT
{
    &nbs ......

VB 取得指定exe文件版本号

【函数】  
  GetFileVersionInfo  
   
  【操作系统】  
  Win9X:Yes  
  WinNT:Yes  
   
  【声明】  
  GetFileVersionInfo   Lib   "version.dll"     Alias   "GetFileVersionInfoA"   (ByVal   lptstrFilename   As   String,   ByVal   dwHandle   As   Long,   ByVal   dwLen   As   Long,   lpData   As   Any)   As   Long  
   
  【说明】  
   
      从支持版本标记的一个模块里获取文件版本信息    
   
  【返回值】  
   
      Long,非零表示成功,零表示失败。会设置GetLastError    
   
  【其它】  
   
      请看vb的api文本查看器中的声明:Declare   Function  
      GetFileVersionInfo   ......

VB使用CopyMemory字符串处理

不能直接使用CopyMemoryStr,应该将字符串转为byte数组,然后使用CopyMemory
Property Get item() As String
    If h = 0 Then ErrRaise ERROR_INVALID_DATA
    'BugAssert p <> pNull
    Dim c As Long, ptr0 As Long
    Dim ab() As Byte
    '取出BSTR的长度
    CopyMemory c, ByVal p, 4
    If c > 0 Then
        ReDim ab(c - 1)
        CopyMemory ByVal VarPtr(ab(0)), ByVal (p + 4), c
        item = ab
    End If
End Property
Property Let item(s As String)
    If h = 0 Then ErrRaise ERROR_INVALID_DATA
    'BugAssert p <> pNull
    Dim c As Long
    Dim ab() As Byte
    c = LenB(s)
    ab = s
    ' 重新将BSTR放回内存中
    C ......

vb class Property Get、Property Let 使用

vb class Property Get、Property Let 使用
<%
'在 Class 块中,成员通过相应的声明语句被声明为 Private(私有成员,只能在类内部调用) 或 Public(公有成员,可以在类内外部调用) 。
'被声明为 Private 的将只在 Class 块内是可见的。被声明为 Public 不仅在 Class 块的内部是可见的,对 Class 块之外的代码也是可见的。
'没有使用 Private 或 Public 明确声明的被默认为 Public。在类的块内部被声明为 Public 的过程(Sub 或 Function)将成为类的方法。
'Public 变量将成为类的属性,同使用 Property Get、Property Let 和 Property Set 显式声明的属性一样。
'类的缺省属性和方法是在它们的声明部分用 Default 关键字指定的。
Class myClass
'//----声明(声明就是定义)myClass类的类内部(私有的[Private])变量
Private strAuthor
Private strVersion
Private strExample
'//---------------------------定义类的事件-------------------------------//
'//----Class_Initialize()是类的初始化事件,只要一开始使用该类,首先会触发该部分的执行.
'下面我们会在该成员中初始化该类的作者和版本以在屏幕上显示一下该类已经开始了
Private Sub C ......
总记录数:380; 总页数:64; 每页6 条; 首页 上一页 [29] [30] [31] [32] 33 [34] [35] [36] [37] [38]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号