內容摘要:這是使用em_getline message來做,比較奇特的是lparam是指向乙個字串所在的位置, 但是該字串傳入時,前兩個byte要存該字串允許的最大長度。 以下在form需乙個…
這是使用em_getline message來做,比較奇特的是lparam是指向乙個字串所在的位置, 但是該字串傳入時,前兩個byte要存該字串允許的最大長度。
'以下在form需乙個textbox,並設定multiline = true, 乙個command button
private sub command1_click()
dim str5 as string
str5 = getaline(text1,1) '取得第二行的字串,以0為基底
end sub
'以下在.bas
option explicit
const em_getline = &hc4
declare function sendmessage lib "user32" alias "sendmessagea" _
(byval hwnd as long, byval wmsg as long, byval wparam as long, _
lparam as any) as long
public function getaline(text1 as textbox, byval ntx as long) as string
dim str5(255) as byte '如果您的字串 > 255 byte請自行增加該byte array
dim str6 as string, i as long
str5(0) = 255 '字串的前兩個byte存該字串的最大長度
str5(0) = 255
i = sendmessage(text1.hwnd, em_getline, ntx, str5(0))
if i = 0 then
getaline = ""
else
str6 = strconv(str5, vbunicode)
getaline = left(str6, instr(1, str6, chr(0)) - 1)
end if
end function
更改檔案,某一行
1 deffetch data 2print 這是查詢功能 3 tag false 4 data aaaa s n data 5 res data 6 with open bbb r encoding gbk as file 7for i in file 8if i data 9 tag true ...
python刪除某一行
整理了網路上的一些方法,一般有兩種方法 第一種 是先把檔案讀入記憶體,在記憶體中修改後再寫入原始檔。例子 將內容包含 123 的所有行刪去 with open c users lai desktop 1.txt r as r lines r.readlines with open c users l...
MFC修改list某一行
指定改變listctrl中某一行的顏色,比如說剛新增進去的一行,讓它改變顏色,這樣記錄多了,容易看到自己剛剛加如的行,方便操作可檢視,也可以讓新增和修改的記錄顯示不一樣的顏色,方便的多了,vc自帶的沒有這種功能。1 首先從clistctrl 繼承乙個類,命名為cmylistctrlnew 在標頭檔案...