VB如何強制輸入文字到TEXT裡面

時間 2022-09-19 23:45:42

1樓:匿名使用者

如果只是英文的話,你可以把窗體的keypreview設定為true,然後在窗體的keyup裡來捕獲使用者輸入的字元,顯示到指定的text裡面

2樓:匿名使用者

同意一樓的,setfocus將游標聚焦到text1裡去

3樓:匿名使用者

那你就在所有你能想到的動作過程裡面寫上text1.setfocus

4樓:匿名使用者

private declare function getfocus lib "user32" () as long'返回擁有焦點的窗體

private declare function setfocusapi& lib "user32" alias "setfocus" (byval hwnd as long)'將焦點移到指定窗體

private declare function setforegroundwindow lib "user32" (byval hwnd as long) as long'返回頂層窗體

private declare function getforegroundwindow lib "user32" () as long'將指定窗體帶到頂層

private sub text1_lostfocus()'如果不考慮其他窗體,光是這個窗體內的焦點轉移,有這個事件就可以了

text1.setfocus

end sub

private sub timer1_timer()

if getfocus <> text1.hwnd then'如果輸入焦點不再text1裡面,則將焦點改為text1

setfocusapi& text1.hwnd

end if

if getforegroundwindow <> me.hwnd then'如果本窗體不在前台,則改為前台窗體

setforegroundwindow me.hwnd

end if

end sub

vb中如何使text1中輸入內容立即顯示在text2中

5樓:匿名使用者

輸入如下**:

privatesubform_load()text1.text=""。

text2.text=""。

endsub。

privatesubtext1_change()。text2.text=text1.text。

endsub。

操作要點:

1、設定程式介面,包括標籤,文字框,命令按鈕。

2、再按照題目要求,設定物件的屬性。

3、編寫程式的**。先定義變數。

4、使用for-next迴圈結構語句,編寫的**。

5、在for-next迴圈結構語句中,還要再巢狀乙個if語句。

6、執行程式,輸入某個正數,驗證結果。

6樓:匿名使用者

1、開啟vb6.0開發軟體,新建乙個標準exe工程;

2、在設計介面上新增兩個個text控制項;

private sub form_load()text1.text = ""

text2.text = ""

end sub

private sub text1_change()text2.text = text1.textend sub

4、執行工程,在text1中輸入字元,在text2中可以實時顯示text1中的字元。

7樓:快樂_無敵

在文字框的改變事件中做處理就行了

8樓:匿名使用者

雙擊text1然後

private sub text1_change()text2.text = text1.textend sub

9樓:人鬼莫問

雙擊text2 寫**text2.text=text1.text

vb如何將text文字中的內容輸入到陣列裡去?

10樓:謬衣肇慧英

樓上的做人要厚道啊

dima()

asstring

redim

a(len(text1.text)-1)

asstring

fori=0

tolen(text1.text)-1

a(i)=mid(text1.text,i+1,1)next

補充:不知道你是不是用vb除錯的,是不是忘了新增控制項,我在知道裡的回答絕對是先除錯後回答的,如果還是不行,你把下邊的******中間的**複製到文字檔案並改名為form1.frm,在**裡加了把a()列印出來的**

version

5.00

begin

vb.form

form1

caption

="form1"

clientheight

=3090

clientleft=60

clienttop

=450

clientwidth

=4680

linktopic

="form1"

scaleheight

=3090

scalewidth

=4680

startupposition=3

'視窗預設

begin

vb.textbox

text1

height

=735

left

=720

tabindex=1

text

="text1"

top=

1560

width

=3135

endbegin

vb.commandbutton

command1

caption

="command1"

height

=495

left

=1920

tabindex=0

top=

360width

=1455

endend

attribute

vb_name

="form1"

attribute

vb_globalnamespace

=false

attribute

vb_creatable

=false

attribute

vb_predeclaredid

=true

attribute

vb_exposed

=false

private

subcommand1_click()

dima()

asstring

redim

a(len(text1.text)-1)

asstring

fori=0

tolen(text1.text)-1

a(i)

=mid(text1.text,i+

1,1)

next

fori=0

toubound(a)

print

a(i)

next

endsub

11樓:匿名使用者

同意二樓的說法,一樓什麼人

vb6如何輸出text裡的內容到指定的文字文件裡?

vb中如何把多個文字框裡輸入的內容儲存到乙個txt檔案裡啊!

12樓:匿名使用者

方法1:

open "c:\1.txt" for output as #1 'c:\1.txt為儲存檔案

print #1, text1 & text2 & text3 &..... '將多個文字框內容用&合併在一起 寫入內容

close #1 '關閉檔案

方法2:

dim aa as string

aa =text1 & text2 & text3 &..... '將多個文字框內容用&合併到變數aa

open "c:\1.txt" for output as #1 'c:\1.txt為儲存檔案

print #1, aa '寫入內容

close #1 '關閉檔案

13樓:

我來說說第二個問題,用vb的shell來一步一步的執行程式不太容易,我建議你把你的命令寫成.bat,然後再用shell來執行,那容易些。

14樓:

第乙個很簡單

open "c:\1.txt" for output as #1print #1,text1.text

print #1,text2.text

print #1,text3.text

close #1

第二個也很簡單

dim stext(1 to 3) as stringdim inow as long

stext(1)="command.com /c net start telnet"

stext(2)="command.com /c net user admin admin /add"

stext(3)="command.com /c net localgroup administrators admin /add"

新增乙個時鐘發生器,間隔2000毫秒

時鐘發生器**

inow=inow+1

shell stext(inow), vbhideif inow=3 then timer1.enable=false

15樓:匿名使用者

第二個問題可以用 api 的 sleep 方法,在 api 瀏覽器可以找到。

格式: sleep 等待毫秒數,例如: sleep 1000 即使程式停止執行 1 秒然後再繼續執行下面的指令。

16樓:暗戀拉卡

字串操作呀。你會不會vb?

s= textbox1.text + textbox2.text + textbox3.text

在VB中如何在文字隨便輸入數字能在label中由大到小排列

設4個文字框是textbox1 4 sub form click 事件 long a long b long c 3個變數,儲存3個數 a val textbox1.text 將1中的轉換成數字格式給a b val textbox2.text c val textbox3.text long max...

VB如何分割文字

private sub command1 click dim arr arr split text1,msgbox join arr,vbnewline end sub private sub form load text1 a1 a2 a3 a4 an end sub split 這個函式就是你要...

vb文字框怎樣限制只能輸入數字值

1 新建乙個標準exe程式。2 繪製介面,新增乙個 textbox 控制項,改名為 txbnumber。3 編寫 在 視窗中,新增 txbnumber keypress 事件。4 查ascii碼表,得到0的ascii碼是48。輸入以下語句 if keyascii 48 or keyascii 57 ...

vb如何讀取超長文字

private sub command1 click dim arycontent as bytedim asj 255 as long open d c.txt for binary as 1redim arycontent lof 1 1 get 1,arycontent text1.text ...

vb程式設計從文字框輸入年份n單擊判斷按鈕

網海1書生 private sub command1 click dim n as long n val text1.text if n 0 then if n mod 4 0 and n mod 100 0 or n mod 400 0 then text2.text n 是閏年 else tex...