花了我好长时间……
Private
Sub
Form_Click()
Dim
i
As
Long
Dim
a(1
To
1000)
As
Long
For
i
=
1
To
1000
a(i)
=
i
i
If
Len(CStr(a(i)))
-
Len(CStr(i))
<>
0
And
Mid(CStr(a(i)),
Int(Len(CStr(a(i)))
-
Len(CStr(i))
+
1),
Len(i))
=
i
Then
i;
End
If
Next
i
End
Sub
不懂的地方我会帮你解释的
'//首先你需要在Form1上面创建一个名称为Text1的TextBox
'//一个名为Command1的按钮和一个名为Command2的按钮
'//一个名为Picture1的PictureBox
'//然后再创建一个Form2,上面必须有一个名为Text1的TextBox
'//Form2上面也要有一个名为Command1的按钮和一个名为Command2的按钮
'//然后将下面的代码找对地方复制过去就行了
'//再添加一个Form3
'//关于Tab顺序的问题,你自己去调每个可 *** 作控件的TabIndex
'//Form2的TextBox需要填上完整路径比如:C:\桌面\text_XXXXtxt
'//另外如果可以能不能留下你的邮箱······ 这样发真的很麻烦···
'////////////////////////////////////////////////////////////////////////////////////////////////////////////Form1
Dim teum As String
Option Explicit
Private Sub Check1_Click(index As Integer) '//检测点击的哪一个复选框
If p = True Then
p = False
Exit Sub
End If
If Check1(index)Value = 1 Then
teum = Text1text '//记录未排序的结果
Else
Text1text = teum '//将未排序的结果返还给文本框
model = 0
End If
Select Case index
Case 1
Call click(Check1(1))
model = 1
Case 2
Call click(Check1(2))
model = 2
End Select
End Sub
Private Sub Command1_Click() '//生成乘法表(这个地方推荐你改改··· 我不知道你打算把这个打印出来的乘法表放哪里···)
If checkNumLen(Form1Text1text) = False Then
Exit Sub
End If
Load Form3
End Sub
Private Sub Command2_Click() '//打开生成文件窗口,并将其设置为模式窗口
Form2Show vbModal
End Sub
Private Sub Form_Load()
model = 0
End Sub
Private Sub Text1_Change()
Text1BackColor = vbWhite
End Sub'/////////////////////////////////////////////////////////////////////////////////////////////////////////////Form2
Option Explicit
Private Sub Command1_Click()
Dim file As String
Dim s As String
Dim txt As String
p = True
If Form1Text1text = "" Then
MsgBox "被写入的数据不能为空!", vbCritical, "提示:"
p = False
Exit Sub
ElseIf checkNumLen(Text1text) = False Then
Form1Text1BackColor = &HC0C0FF
MsgBox "被写入数据不符合条件!", vbCritical, "提示:"
p = False
Exit Sub
End If
If model = 0 Then
s = "未排序的"
ElseIf model = 1 Then
s = "从小到大排序的"
ElseIf model = 2 Then
s = "从大到小排序的"
End If
If Text1text = "" Then
MsgBox "请输入文件路径!", vbCritical, "提示:"
p = False
ElseIf Dir(Text1text) = "" Then
MsgBox Text1text & vbCrLf & "文件不存在!", vbExclamation, "提示:"
p = False
Else
file = Text1text
txt = Form1Text1text
If MsgBox("确定要写入当前数据?" & vbCrLf & "当前数据是" & s, vbExclamation + vbOKCancel, "提示:") = vbOK Then
Open file For Output As #1 '//打开目标文件,访问方式:顺序访问
Write #1, Val(txt)
Close #1 '//关闭目标文件
MsgBox "写入完毕!", vbInformation, "提示:"
End If
End If
End Sub
Private Sub Command2_Click()
Dim file As String
Dim txt As String
Dim txtread As String
If Text1text = "" Then
MsgBox "请输入文件路径!", vbCritical, "提示:"
Exit Sub
ElseIf Dir(Text1text) = "" Then
MsgBox Text1text & vbCrLf & "文件不存在!", vbExclamation, "提示:"
Exit Sub
Else
file = Text1text
txt = Form1Text1text
Open file For Input As #1 '//打开目标文件,访问方式:顺序访问
Do
Line Input #1, txtread
txt = txt & txtread
Loop Until EOF(1) = True
Close #1 '//关闭目标文件
End If
If txt = "" Then
MsgBox "文件为空!", vbExclamation, "提示:"
ElseIf IsNumeric(txt) = False Then
MsgBox "文件内包含非法字符", vbCritical, "提示:"
ElseIf Len(txt) < 3 Then
MsgBox "文件内容不足三位数字", vbCritical, "提示:"
ElseIf IsNumeric(Mid(txt, 3, 1)) = False Then
MsgBox "文件内容第3位不是数字!", vbCritical, "提示:"
Else
MsgBox "文件符合要求!", vbInformation, "提示:"
End If
End Sub'///////////////////////////////////////////////////////////////////////////////////////////////////////////////Form3
Option Explicit
Private Sub Form_Load()
Dim num As Integer
Dim i As Integer
Dim j As Integer
Dim space As String
Show
num = Val(Mid(Form1Text1text, 3, 1)) Mod 2
If num = 0 Then
For i = 1 To 9
For j = 1 To i
If j = 2 And i = 4 Or j = 2 And i = 3 Then
space = " "
Else
space = " "
End If
Print j & "×" & i & "=" & j i & space;
Next j
Next i
Else
For i = 9 To 1 Step -1
For j = 1 To i
If j = 2 And i = 4 Or j = 2 And i = 3 Then
space = " "
Else
space = " "
End If
Print j & "×" & i & "=" & j i & space;
Next j
Next i
End If
End Sub'///////////////////////////////////////////////////////////////////////////////模块文件
Option Explicit
Public p As Boolean
Public model As Integer
Public Function sort(content As String, style As Integer) '//排序函数,content 必选参数,需要排序的内容;style 必选参数,用于规定排序方式
Dim a(9) As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim t As Integer
For i = 0 To Len(content) - 1 '//给排序数组用赋值
a(i) = Val(Mid(content, i + 1, 1))
Next i
'//排序方法:选择排序
If style = 1 Then '//从小到大
For j = 0 To Len(content) - 2
For k = j + 1 To Len(content) - 1
If a(j) > a(k) Then
t = a(j)
a(j) = a(k)
a(k) = t
End If
Next k
Next j
ElseIf style = 2 Then '//从大到小
For j = 0 To Len(content) - 2
For k = j + 1 To Len(content) - 1
If a(j) < a(k) Then
t = a(j)
a(j) = a(k)
a(k) = t
End If
Next k
Next j
End If
For i = 0 To Len(content) - 1 '//排序将结果交给文本框
sort = sort & a(i)
Next i
End Function
Public Function checkNumLen(content As String) '//条件检测函数,content 必选参数,需要排序的内容
Dim i As Integer
If Len(Form1Text1text) < 8 Or Len(Form1Text1text) > 10 Then
If p = False Then
Form1Text1BackColor = &HC0C0FF
MsgBox "请输入8~10位的正整数", vbCritical, "提示:"
model = 0
Form1Text1SetFocus
p = True
For i = 1 To Form1Check1UBound
Form1Check1(i)Value = 0
Next i
p = False
End If
Else
checkNumLen = True
End If
End Function
Public Function click(Obj As Object) '//点击检测函数
Dim i As Integer
If checkNumLen(Form1Text1text) = False Then
Exit Function
Else
If ObjValue = 1 Then
For i = 1 To Form1Check1UBound
If i <> Objindex Then
Form1Check1(i)Value = 0
End If
Next i
Form1Text1text = sort(Form1Text1text, Objindex) '//调用排序函数
End If
End If
Form1Text1SetFocus
Form1Text1SelStart = Len(Form1Text1text)
End Function
#include <stdioh>
void main()
{
float x,y;
scanf("%f",&x);
if((x>=0)&&(x<=8))
{
y=x+2xx+10;
}
else
{
y=x-3xxx-9;
}
printf("%f\n",y);
}
#include <stdioh>
void main()
{
float x,y,z;
scanf("%f %f",&x,&y);
if((x>=0)&&(y>=0))
{
z=xx+yy;
}
if((x<0)&&(y<0))
{
z=xx-yy;
}
if((x>0)&&(y<0))
{
z=x+y;
}
if((x<0)&&(y>0))
{
z=x-y;
}
printf("%f\n",z);
}
以上就是关于一个关于VB的程序编写!!在线等!!全部的内容,包括:一个关于VB的程序编写!!在线等!!、用vs2012编写vb程序。在线等急求!!!!、用C语言编写下列程序,在线急求!!!!!!!!!!!!!!!!!,画红线的!!!!!!!!!大神来等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)