「トップページ/VB6/SAMPLE」の編集履歴(バックアップ)一覧に戻る
サンプルコード |
'Variant型の空の配列を作る Dim arr() As Variant arr = Array() '空っぽの判定 On Error Resume Next If (UBound(arr)) Then Debug.Print "配列は空っぽ" End If 'String型の空の配列を作る Dim StringArray() As String StringArray = Split("") 'Byte型の空の配列を作る Dim ByteArray() As Byte ByteArray = "" 'Object型の空の配列を作る Dim ObjectArray() As Object Call IsArray(ObjectArray)
Private Declare Function SafeArrayAllocDescriptor Lib "oleaut32" ( _ ByVal cDims As Long, ByRef ppsaOut() As Any) As Long Private Declare Sub GetMem4 Lib "msvbvm60" ( _ ByVal ptr As Long, ByRef ret As Long)
Dim arr() As Integer ReDim arr(0) '空っぽの判定(本当は要素数1である) If (UBound(arr) = 0) Then '... End If '要素数を5に変更(本当は要素数6になる) ReDim arr(5) 'ループ処理(cntは0~4の値となる) Dim cnt As Integer For cnt = 0 To UBound(arr) - 1 '... Next cnt '末尾に要素を追加 ReDim Preserve arr(UBound(arr) + 1) arr(UBound(arr) - 1) = 0
'source:取り出し元 / destination:取り出したデータ Dim source as Long, destination as Long '最下位バイトを取り出す dest = src & 0xff destination = source And &HFF& '2バイト目を取り出す dest = (src >> 8) & 0xff destination = (source / &H100) And &HFF& '3バイト目を取り出す dest = (src >> 16) & 0xff destination = (source / &H10000) And &HFF& '最下位バイトを取り出す dest = (src >> 24) & 0xff destination = (source / &H1000000) And &HFF&
Dim fno as Integer, str As String fno = FreeFile Open "c:\sample.txt" For Input As #fno Line Input #fno, str Close #fno