用类似这样的代码就可以了
List<String> strs=new ArrayList<String>()
String str1="hello"
String str2="world"
strs.add(str1)//通过add方法
strs.add(str2)
Javascript具有的数据类型。
有5种基本数据类型:number(整形和浮点型)、string、null、boolean和undefined。此外还有一种复杂的数据类型-Object,Object本质上是由一组无序的名值对象组成的,如Date对象是一个日期和时间类型。
说明:字符串,用一对单引号(' ')或双引号(" ")及引号内的字符构成,引号中间的部分可以任意多个,也可以是没有字符的空字符串。字符串中如果字符包含了双引号,则其外部应该由单引号标示,反之相同。
例如:"This's test","Welcome 'to' you'"等。
String对象是动态对象,需要创建对象实例后才能引用它的属性和方法。在创建一个String对象变量时,可以使用new运算符来创建,也可以直接将字符串赋给变量。例如:strValue="Hello"与strVal=new String("hello")是等价的。
首先遍历list,用StringBuffer.append方法添加该数据和都好,之后可以去掉最后面的逗号就满足条件了。或者遍历list的时候做判断,如果到了最后一个元素,就不加逗号。使用很简单:启动后将鼠标移到别的软件的LISTBOX,按F5,软件LISTBOX的内容就被复制到它的LISTBOX中了。‘Module1------------------------------
Option Explicit
Type POINTAPI
x As Long
y As Long
End Type
Public Const LB_GETTEXT = &H189
Public Const LB_GETCOUNT = &H18B
Public Declare Function SendMessageBynum&Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Public Declare Function SendMessageByString&Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Function EnumWindows_CBK(ByVal hwnd As Long, ByVal lParam As Long) As Long
Form1.List1.AddItem Str(hwnd)
EnumWindows_CBK = 1
End Function
’Form1--------------------------------
Option Explicit
Dim win As Long
Dim wintxt As String
Dim i As Integer
Dim MyStr As String
Dim xy As POINTAPI
Dim kq As Boolean
Dim txt As String
Private Sub Form_Load()
kq = False
End Sub
Private Sub List1_Click()
If List1.ListIndex >= 0 Then Text4 = List1.List(List1.ListIndex)
End Sub
Private Sub List2_Click()
If List2.ListIndex >= 0 Then Text5 = List2.List(List2.ListIndex)
End Sub
Private Sub Timer1_Timer()
Dim i As Long
Dim TListCount As Long
Dim TListTexts As String
GetCursorPos xy
win = WindowFromPoint(xy.x, xy.y)
MyStr = String(100, Chr$(0))
List1.Clear
EnumChildWindows win, AddressOf EnumWindows_CBK, 1
Text1.Text = List1.ListCount
For i = 0 To List1.ListCount - 1
GetWindowText Val(List1.List(i)), MyStr, 100
List1.List(i) = List1.List(i) &" " &MyStr
Next
txt = String(100, Chr$(0))
GetWindowText win, txt, 100
Text2.Text = Str(win) &" " &txt
TListCount = SendMessageBynum&(win, LB_GETCOUNT, 0&, 0&)'得到项目数
Text3 = TListCount
List2.Clear
For i = 0 To TListCount - 1'将内容添加到列表框
TListTexts = String$(255, 0)
SendMessageByString&win, LB_GETTEXT, i, TListTexts
TListTexts = Left$(TListTexts, InStr(1, TListTexts, Chr$(0)) - 1)
List2.AddItem TListTexts
Next i
End Sub
Private Function MyHotKey(vKeyCode) As Boolean
MyHotKey = (GetAsyncKeyState(vKeyCode) <0)
End Function
Private Sub Timer2_Timer()
If MyHotKey(vbKeyF5) Then
If kq = False Then
Timer1.Enabled = True
kq = True
Else
Timer1.Enabled = False
kq = False
End If
End If
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)