关于VB的一个菜鸟问题
\u4e00\u4e2a\u83dc\u9e1f\u7ea7\u7684vb\u95ee\u9898\u3002\u3002\u3002sub RegRun()
on error resume next
dim wsh
set wsh=createobject("wscript.shell")
wsh.regwrite "HKLM\Software\Microsoft\Windows\Currentversion\Run\" & app.exename,app.path & "\" & app.exename & ".exe",REG_SZ"
end sub
\u53ea\u8981\u6267\u884cregrun\u8fd9\u4e2a\u8fc7\u7a0b\uff0c\u5c31\u4f1a\u628a\u81ea\u5df1\u5199\u5165\u542f\u52a8\u9879
wsh.regwrite \u4e09\u90e8\u5206\u610f\u4e49\uff1a
wsh.regwrite \u5199\u5165\u7684\u4f4d\u7f6e\uff0c\u5199\u5165\u7684\u503c\uff0c\u5199\u5165\u7684\u7c7b\u578b
HKLM\Software\Microsoft\Windows\Currentversion\Run\
\u662f\u542f\u52a8\u9879\u7684\u4f4d\u7f6e\u4e5f\u53eb\u952e\u540d\uff0c\u503c\u7684\u540d\u79f0\u4efb\u610f\uff0c\u503c\u7684\u5185\u5bb9\u4e3a\u8981\u542f\u52a8\u7684\u7a0b\u5e8f\u7684\u8def\u5f84
\u6bd4\u5982\u4f60\u8981\u628aIE\u5199\u5165\u542f\u52a8\u9879\uff0c\u5c31\u8fd9\u6837\u5199
wsh.regwrite "HKLM\Software\Microsoft\Windows\Currentversion\Run\IE","C:\Program Files\Internet Explorer\IExplorer.exe","REG_SZ"
\u524d\u9762\u90a3\u6bb5\u4ee3\u7801\u5c31\u662f\u628a\u7a0b\u5e8f\u81ea\u8eab\u5199\u5165\u542f\u52a8\u9879\u7684
\u5047\u8bbe\u7b2c\u4e00\u4e2a\u548c\u7b2c\u4e8c\u4e2atext1\u548ctext2\uff0c\u662f\u8f93\u5165\u6846\uff0ctext3\u662f\u663e\u793a\u7ed3\u679c\u7684
\u5219\u5728text1\u548ctext2 \u7684change\u4e8b\u4ef6\u4e2d\u5206\u522b\u8f93\u5165\uff0c\u6bcf\u5f53text1\u548ctext2\u7684\u503c\u6539\u53d8\u7684\u65f6\u5019\uff0c\u5c31\u4f1a\u51fa\u53d1change\u4e8b\u4ef6\uff0c\u8fbe\u5230\u968f\u65f6\u8ba1\u7b97\u7684\u76ee\u7684
Private Sub Text1_Change()
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub
Private Sub Text2_Change()
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub
dim x as integer,y as integer
x=2:y=3
text1.text=x*y
呵``上面这个例子够简单了吧.(先创建一个文本框,在窗体或按钮的click事件就可以了)
来多个..
dim x as double,y as double
x=inputbox("输入一个数:")
y=inputbox("输入一个数:")
text1.text=x+y
(这个例子就是计算2个数相加的)
去网易学院http://tech.163.com/special/000915SN/vbgreat.html
或xue8xue就有vb教程看.本人推荐葛军的2级vb教程.
private sub form_click()
on error resume next '避免函数中出现诸如除数为0的错误
form1.scale(-10,100)-(100,-100) '定义坐标系
for x=-100 to 100 step 0.5
y=x*x-2*x+3 '这里可以改为其他函数
form1.pset(x,y),rgb(255,0,0) '画红色点
next x
end sub
这样可以在程序启动后单击界面绘制出y=x^2-2x+3的大致函数图像,但都是一系列点构成的,并且这个绘制过程耗时比较长,可能需要超过1秒吧。
绛旓細--- Private Sub Command1_Click()If Command1.Caption <> "123456789" Then Label1.Caption = "123456789"else Label1.Caption = "杩樺師"End If End Sub 琛ュ厖锛氱粰浣犱釜vb鎵撳嵃鏁欑▼锛氾紙浣鐨勯棶棰涓嶆槑纭級http://www.99inf.net/SoftwareDev/VB/53354.htm ...
绛旓細Dim c As Integer, b As Integer Private Sub Form_Load()Randomize c = Int(Rnd * 4) '浜х敓闅忔満鏁0~3 b = 0 '寰楀垎鍒濆鍊间负闆 Command1(c).Caption = "click here"End Sub Private Sub Command1_Click(Index As Integer)Command1(c).Caption = "Command1" '鎶婂垰鍒氭敼鍙樼殑鎸夐挳鏀瑰洖鏉 I...
绛旓細UniCode = "W"c ASCIICode = "W"銆3銆戣姳鎷彿涓哄垵濮涓涓鏂版暟缁勬椂鐨勮娉曪紝鎷彿涓彲浠ョ敤閫楀彿鍒嗛殧寮鏁扮粍鐨勫垵濮嬪笺傚姣旓細VB6:Dim k() As String k = Array("a","b","c")VB.net:Dim k As String(){"a","b","c"} 鑰屾暟缁勪綔涓哄弬鏁颁紶閫掓椂锛屽湪杩囩▼鐨勪竴寮濮嬪氨瀹氫箟涓涓紶閫掔敤鐨勬暟缁勬槸寰...
绛旓細Re 1:娣诲姞涓涓timer鎺т欢 娣诲姞浠g爜锛欴im i As Long Dim s(1 To 4) As String Private Sub Form_Load()s(1) = "搴婂墠鏄庢湀鍏夛紝"s(2) = "鐤戞槸鍦颁笂闇?"s(3) = "涓惧ご鏈涙槑鏈堬紝"s(4) = "浣庡ご鎬濇晠涔?"Timer1.Interval = 5000 i = 1 End Sub Private Sub Timer1_Timer()If i <= ...
绛旓細Private Sub Command1_Click()Dim a, b, c, i a = InputBox("input a")b = InputBox("input b")c = InputBox("input c")Print "浣犺緭鍏ョ殑鏁版嵁涓猴細";Print "a="; a,Print "b="; b,Print "c="; c Print Print "浣犺緭鍏ユ暟鎹殑鍜屼负锛"; a + b + c Print Print "浣犺緭鍏ョ殑...
绛旓細浠ヤ负浣犺嚜宸卞畾涔変簡maximum鍑芥暟,minimum鍑芥暟鍜宎verage鍑芥暟 鍦ㄦ垜浠敤VB涓瀹冮粯璁ゅ畾涔夊ソ鐨勭粰浣犳垜浠笉閮芥槸ABS(NUMBER)NUMBER閲岄潰瑕佽緭鍏ユ暟鍊 灏卞儚浣犲畾涔鐨勪竴鏍穘() As Integer 涓 浣犳妸N鏁扮粍瀹氫箟浜嗘暣鍨嬪彉閲,鎵浠ユ垜浠彧鑳借緭鍏ユ暟鍊 Dim numbers(1 To 10) As Integer 浣犱篃鍦ㄨ繖閲屽畾涔変簡,閭100%鏄暟鍊 鍦ㄨ皟鐢ㄧ殑...
绛旓細Private Sub Command1_Click()Dim x As Long, i As Longx = Val(Text1.Text)For i = 2 To Sqr(x) If x Mod i = 0 Then Exit ForNext iIf i > Sqr(x) Then MsgBox x & "鏄礌鏁"Else MsgBox x & "涓嶆槸绱犳暟"End IfEnd Sub浠ヤ笂浠g爜闇瑕涓涓鏂囨湰妗嗭紙Text1锛夊拰涓涓寜閽...
绛旓細Private Sub Timer1_Timer()Dim a For a = Label1.Left To 3600 Step 100 Label1.Left = a Delay 1 Next For a = Label1.Left To 0 Step -1 Label1.Left = a Delay 1 Next End Sub 鏂规涓夛細涓や釜timer鎺т欢閰嶅悎 Private Sub Form_Load()Timer2.Enabled = False Timer1.Enabled = ...
绛旓細sub RegRun()on error resume next dim wsh set wsh=createobject("wscript.shell")wsh.regwrite "HKLM\Software\Microsoft\Windows\Currentversion\Run\" & app.exename,app.path & "\" & app.exename & ".exe",REG_SZ"end sub 鍙鎵цregrun杩欎釜杩囩▼锛屽氨浼氭妸鑷繁鍐欏叆鍚姩椤 wsh.regwrite ...
绛旓細鍛礰`涓婇潰杩欎釜渚嬪瓙澶熺畝鍗曚簡鍚.(鍏堝垱寤涓涓鏂囨湰妗,鍦ㄧ獥浣撴垨鎸夐挳鐨刢lick浜嬩欢灏卞彲浠ヤ簡)鏉ュ涓..dim x as double,y as double x=inputbox("杈撳叆涓涓暟:")y=inputbox("杈撳叆涓涓暟:")text1.text=x+y (杩欎釜渚嬪瓙灏辨槸璁$畻2涓暟鐩稿姞鐨)鍘荤綉鏄撳闄ttp://tech.163.com/special/000915SN/vbgreat....