「トップページ/VB6/SAMPLE」の編集履歴(バックアップ)一覧はこちら

トップページ/VB6/SAMPLE - (2011/01/11 (火) 13:08:06) の1つ前との変更点

追加された行は緑色になります。

削除された行は赤色になります。

|&big(){サンプルコード}| #contents() ---- *ビット演算 -指定位置のバイトを取り出す '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
|&big(){サンプルコード}| #contents() ---- *空の配列 C#でいうところの、nullが入った状態のことである。 基本的にVB6では、空っぽのの配列を作成することはできない。 しかし、偉大な先人達が、いくつかの方法を見つけている。 +Nothingを入れておく方法 +APIを使う方法 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) 読みやすさを考えて 「常に目的のサイズ+1とし、サイズ1を空とみなす方法」 が好ましいと考える。 ---- *ビット演算 -指定位置のバイトを取り出す '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

表示オプション

横に並べて表示:
変化行の前後のみ表示: