2010-01-20から1日間の記事一覧

スクロールバー CScrollBar

SBS_HORZで水平スクロールバー CScrollBar bar; ・・・ int Test::OnCreate(LPCREATESTRUCT lpCreateStruct) bar.Create( SBS_HORZ , RECT( スクロールバーの座標 ) , this , <ユニークな数値> ); bar.SetScrollRange(0,255); // 幅設定 bar.ShowWindow( SW_…

文字の検索

文字列中に含まれている任意文字列の位置を求める無かったらnilが返る s = "Apple Banana Apple Orange" p s.index("Apple") #=> 0 p s.index("Banana") #=> 6 p s.index("Apple", 6) #=> 13 p s.rindex("Apple") #=> 13 p s.rindex("Apple", 6) #>= 0ネタ元…

Zipの解凍

ziprubyというライブラリがいるのでインストール gem install ziprubyコードはこんな感じ require 'rubygems' require 'zipruby' Zip::Archive.open('test.zip') do |ar| ar.fopen(ar.get_name(0)) do | file | fileName = file.name content = file.read en…

ファイル出力

foo = File.open("foo.txt",'w') foo.puts 'bar' foo.closeネタ元 http://www.namaraii.com/rubytips/?%A5%D5%A5%A1%A5%A4%A5%EB%A5%A2%A5%AF%A5%BB%A5%B9#l9

CSVファイルを読み込む

一行ずつ読み込むサンプル require 'csv' ・・・ CSV.open('test.csv', 'r') do |row| p row[0] # 0番目の要素表示 endネタ元 http://d.hatena.ne.jp/gom68/20090213/1234523232

ファイル選択ダイアログ

require 'win32ole' require 'vr/vruby' ・・・ file=SWin::CommonDialog::openFilename(nil,[["CSV(*.csv)","*.csv"],["all(*.*)","*.*"]],0x1000) wsh = WIN32OLE.new('WScript.Shell') if file wsh.Popup(file,0, "選択されたファイルは") else wsh.Popup…

ハッシュ Hash

解説 http://www.rubylife.jp/ini/hash/index3.html 数値以外でもキーにできる配列なイメージ test_hash = Hash.new test_hash[0] = 1234 test_hash['abc'] = 5678