求VB大佬看看!!谢谢!!代码怎么写!!

求VB大佬看看!!谢谢!!代码怎么写!!,第1张

本程序使用了控件数组:


代码:

Private Type Student

Stu_ID As String

Name As String

Sex As String

PoliticalOrientation(1) As String

End Type

Private Sub Command1_Click()

Dim Stud As Student

With Stud

Stu_ID = Text1Text

Name = Text2Text

For i = 0 To 1

If Option1(i)Value Then Sex = Option1(i)Caption

If Check1(i)Value Then

PoliticalOrientation(i) = Check1(i)Caption

Else

PoliticalOrientation(i) = "非" + Check1(i)Caption

End If

Next i

Picture1Print "学号:" + Stu_ID

Picture1Print "姓名:" + Name

Picture1Print "性别:" + Sex

Picture1Print "政治面貌1:" + PoliticalOrientation(0)

Picture1Print "政治面貌2:" + PoliticalOrientation(1)

Picture1Print

Open "E:\DataFiletxt" For Append As #1

Write #1, Stu_ID; Name; Sex, PoliticalOrientation(0); PoliticalOrientation(1)

Close #1

End With

End Sub

运行效果:

Private Sub Command1_Click()

If Option1Value = True Then

Text2 = Sin(Val(Text1))

End If

If Option2Value = True Then

Text2 = Exp(Val(Text1))

End If

If Option3Value = True Then

Text2 = Sqr(Val(Text1))

End If

If Check1Value = 1 Then

Text2FontBold = True

End If

If Check2Value = 1 Then

Text2FontItalic = True

End If

End Sub

Private Sub Form_Load()

Label1Caption = "参数"

Label2Caption = "结果"

Command1Caption = "计算"

Frame1Caption = ""

Frame2Caption = ""

Option1Caption = "sin"

Option2Caption = "exp"

Option3Caption = "sqr"

Check1Caption = "粗体"

Check2Caption = "斜体"

Text1 = 4

Text2 = ""

Text2BackColor = &H80000006

Text2BorderStyle = 0

Text2FontSize = 20

Option3Value = True

End Sub

style="BORDER-RIGHT:
1px
;
BORDER-TOP:
1px
;
BORDER-LEFT:
1px
;
BORDER-BOTTOM:
1px
dashed">
只有下边框且为虚线
这是我写的代码希望对你有帮助
如果希望修改虚线粗细可改动BORDER-BOTTOM:
1px为2px、3px等
只有下边框且为虚线
为表格标题
表格内容在
之间增删
只要在
之间就可以了

//全写了注释了, 不懂追问 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ExtCtrls; //新建一工程, 放进15个TSpeedButton和一个TEdit然后按照下边的说明设置一下 type TForm1 = class(TForm) //把窗体的KeyPreview属性设置为TRUE SpeedButton1: TSpeedButton; //表示数字键1, Caption属性设置为1 SpeedButton2: TSpeedButton; //表示数字键2, Caption属性设置为2 SpeedButton3: TSpeedButton; //表示数字键3, Caption属性设置为3 SpeedButton4: TSpeedButton; //表示数字键4, Caption属性设置为4 SpeedButton5: TSpeedButton; //表示数字键5, Caption属性设置为5 SpeedButton6: TSpeedButton; //表示数字键6, Caption属性设置为6 SpeedButton7: TSpeedButton; //表示数字键7, Caption属性设置为7 SpeedButton8: TSpeedButton; //表示数字键8, Caption属性设置为8 SpeedButton9: TSpeedButton; //表示数字键9, Caption属性设置为9 SpeedButton10: TSpeedButton; //表示数字键0, Caption属性设置为0 SpeedButton11: TSpeedButton; //表示小数点, , Caption属性设置为 小数点 SpeedButton12: TSpeedButton; //计算结果, 等于(=)号, Caption属性设置为 = SpeedButton13: TSpeedButton; //加号, Caption属性设置为 + , Tag属性设置为 1 SpeedButton14: TSpeedButton; //减号, Caption属性设置为 - , Tag属性设置为 2 Edit1: TEdit; //显示计算结果 SpeedButton15: TSpeedButton; //归零(复位)处理 procedure SpeedButton1Click(Sender: TObject); procedure SpeedButton12Click(Sender: TObject); procedure SpeedButton13Click(Sender: TObject); procedure SpeedButton15Click(Sender: TObject); procedure FormKeyPress(Sender: TObject; var Key: Char); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R dfm} var Flag: Boolean = True; //。标记位 Flag1: Integer = 1; //计算方法标志位 num1, num2, result: Real; flagresult: Boolean = False; procedure TForm1SpeedButton1Click(Sender: TObject); //按住SHIFT键, 再用鼠标点SpeedButton1 至 SpeedButton11(多选), 然后在属性面板双击onClick //以后11个SpeedButton共用一个OnClick事件, var str: string; begin str := Edit1Text; if (Length(str) = 1) and (str = '0') then Edit1Clear; Edit1Color := clBlue; if ((Sender as TSpeedButton)Caption = '') then //小数点处理 begin if Flag then begin Edit1Text := Edit1Text + (sender as TSpeedButton)Caption; Flag := False; end end else Edit1Text := Edit1Text + (sender as TSpeedButton)Caption; end; procedure TForm1SpeedButton12Click(Sender: TObject); //计算并显示结果 begin Edit1Color := clRed; num2 := StrToFloatDef(Edit1Text, 000); case Flag1 of 1: result := num1 + num2; 2: result := num1 - num2; Edit1Text := FloatToStr(result); end; procedure TForm1SpeedButton13Click(Sender: TObject); //按住SHIFT, 用鼠标点SpeedButton13, SpeedButton14(多选), 然后在属性面板双击onClick //以便2个SpeedButton共用一个OnClick事件, begin Flag1 := (Sender as TSpeedButton)Tag; num1 := StrToFloatDef(Edit1Text, 000); Edit1Text := '0'; end; procedure TForm1SpeedButton15Click(Sender: TObject); //归零(复位) begin Flag := True; //。标记位 Flag1 := 1; //计算方法标志位 num1 := 0; num2 := 0; result := 0; Edit1Text := '0'; end; procedure TForm1FormKeyPress(Sender: TObject; var Key: Char); //对窗口按键盘上的数字键时, 做输入 *** 作数处理 begin case key of '1': SpeedButton1Click; '2': SpeedButton2Click; '3': SpeedButton3Click; '4': SpeedButton4Click; '5': SpeedButton5Click; '6': SpeedButton6Click; '7': SpeedButton7Click; '8': SpeedButton8Click; '9': SpeedButton9Click; '0': SpeedButton10Click; '': SpeedButton11Click; '+': SpeedButton13Click; '-': SpeedButton14Click; end; end; end
采纳哦

我做一个,有一个text,2个button,你自己再改,PrivateSubCommand1_Click()Text1Locked=FalseText1Text=""Text1Text="com1"Text1Locked=TrueEndSubPrivateSubCommand2_Click()Text1Locked=FalseText1Text=""Text1Text="com2"Text1Locked=TrueEndSub

Private Sub Command1_Click()
Label1Caption = "开始变色咯" '改变标签文字
Label1ForeColor = rgb(rnd255,rnd255,rnd255) '随机变色
End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/13336886.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-17
下一篇 2023-07-17

发表评论

登录后才能评论

评论列表(0条)

保存