名为Text1的文本框,利用“颜色”对话框将文本框中的字体颜色设置成用户所选择的颜色,为此编写以下程序代码,井按要求将程序补充完整。 Private Sub Command1_Click() CommonDialogl.Flags=cdlCCRGBInit CommonDialogl.Color=Text1.ForeColor 【 】 Text1.ForeColor=CommonDialog1.Color End Sub
文本控件Richtexbox1。要求程序运行以后,用户可以利用。Drivel选择不同驱动器,同时Dirl中显示当前选中的驱动器的目录,用户利用Dirl选择文件所在的文件夹,在Filel控件中将显示当前选中的文件夹下的文件,用户选中其中某个文件(假设为文本文件),则该文件的内容显示在控件Richtexboxl中。补充相应的语句,使之完成所述的功能。 Private Sub Dirl_Change() 【 】 End Sub Private Sub Drive1_Change() 【 】 End Sub Private Sub Filel _Click() Dim fname AS String If【 】Then fname=Filel.Path & Filel.FileName Else fname=Filel.Path& "\" & Filel.FileName End If RichTextBox1.LoadFile(fname) End Sub
框控件(注意:拖动时,文本框移动的距离和方向由鼠标指针移动的距离和方向来确定),按下鼠标右键则可以在文本框中显示出当前文本控件的位置。 Public yx As Integer Public yy As Integer Private Sub Form_ MouseMove(Button AS Integer,Shift As Integer,_ X As Single,Y As Single) If Button=1 Then Text1.Left=【 】 Text1.Top=【 】 End If End Sub Private Sub Form_ MouseDown (Button As Integer,Shift As Integer,_ X As Single,Y As Single) If【 】Then yx=Text1.Left-X yy=Text1.Top-Y End If If Button=2 Then Text1.Text=“X坐标:”+Str(Text1.Left)+“Y坐标:”+Str(Text1.Top) End If End Sub