变量定义面变量名x,y换别x1y1等
Dim
x1
As
Integer
Private
Sub
Command1_Click()'+按钮
x1
=
x1
+
1
MeCaption
=
x1
End
Sub
Private
Sub
Command2_Click()'-按钮
x1=
x1
-
1
MeCaption
=
x1
End
Sub
要知道VB6里只能使用3232像素的图标,通常还有4848像素的图彪,在VB6里不能用。
要知道图标的像素,如果没有专用工具,可以使用 Windows里的画图软件,打开某图标文件,通过菜单 [图像] -- [属性],观察“宽度”和“高度”,都不大于32。
Option Explicit
Private Sub Form_Load()
Randomize
Label1Caption = Int((Rnd (999999 - 100000 + 1)) + 100000) '生成100000-999999之间的随机数
Timer1Interval = 1000 '一秒一次
Timer1Enabled = True
End Sub
Private Sub Timer1_Timer()
Static n As Integer
n = n + 1
If n = 60 Then '一秒一次,累加到60此即60秒
n = 0
Randomize
Label1Caption = Int((Rnd (999999 - 100000 + 1)) + 100000)
End If
End Sub
有问题请追问,,加油!
'用法:: AA "1234"
Function AA(ByVal x As String) As String
Dim ns As Integer
ns = Len(x)
Dim n() As String
Dim w() As Integer
ReDim n(ns)
ReDim w(ns)
Dim i As Integer
For i = 1 To ns
n(i) = Mid(x, ns - i + 1, 1)
Next
Dim str As String
BB n, w, 0, str
MsgBox str
Open "c:\1txt" For Output As #1 ''输出文件句自己改
Print #1, str
Close #1
End Function
Function BB(ByRef n() As String, w() As Integer, ByVal k As Integer, s As String)
Dim i As Integer, j As Integer
Dim b As Boolean
For i = 1 To UBound(n)
b = False
For j = 1 To k
If i = w(j) Then
b = True
Exit For
End If
Next
If Not b And k + 1 <= UBound(n) Then
w(k + 1) = i
BB n, w, k + 1, s
End If
Next
If UBound(w) = k Then
For i = 1 To UBound(w)
s = s & n(w(i))
Next
s = s & vbCrLf
Exit Function
End If
End Function
程序包含一个标签和一个间隔1秒的时间控件
Private xx(1 To 5) As String
Private i As Integer, f As Integer
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 112 Then
f = MsgBox("你按了F1,继续吗?", vbYesNo + vbInformation, "提示")
If f = vbYes Then
Timer1Enabled = True
Else
Call Form_KeyDown(113, 0)
End If
ElseIf KeyCode = 113 Then
MsgBox "你按了F2键,结束应用程序!"
End
End If
End Sub
Private Sub Form_Load()
xx(1) = "aaaaaaaaaa"
xx(2) = "bbbbbbbbbb"
xx(3) = "cccccccccc"
xx(4) = "dddddddddd"
xx(5) = "请按F1、F2"
i = 1
End Sub
Private Sub Timer1_Timer()
Label1Caption = xx(i)
If xx(i) = "请按F1、F2" Then
Timer1Enabled = False
Call Form_KeyDown(112, 0)
End If
i = i + 1
If i > 5 Then i = 1
End Sub
你也可以手动按F1、F2 效果一样!
用VB做万年历,非常关键点就是农历写法,参考代码如下:
#Region " 返回农历 "
'返回农历
'cCalendarMaxSupportedDateTime 返回支持的最大日期,即2101-1-28
'cCalendarMinSupportedDateTime 返回支持的最小日期,即190-2-19
Private cCalendar As New SystemGlobalizationChineseLunisolarCalendar
Public Function PubFunGet_CNDate(ByVal sDateTime As Date) As String
cCalendar = New SystemGlobalizationChineseLunisolarCalendar
Dim lyear As Integer = cCalendarGetYear(sDateTime)
Dim lmonth As Integer = cCalendarGetMonth(sDateTime)
Dim lday As Integer = cCalendarGetDayOfMonth(sDateTime)
Dim lweek As Integer = cCalendarGetDayOfWeek(sDateTime)
'获取闰月, 0 则表示没有闰月
Dim leapMonth As Integer = cCalendarGetLeapMonth(lyear)
Dim isleap As Boolean = False
If (leapMonth > 0) Then
If (leapMonth = lmonth) Then
'闰月
isleap = True
lmonth = lmonth - 1
ElseIf (lmonth > leapMonth) Then
lmonth = lmonth - 1
End If
End If
Return StringConcat(GetLunisolarYear(lyear), IIf(isleap = True, "闰年", "年"), GetLunisolarMonth(lmonth), "月", GetLunisolarDay(lday))
End Function
'十天干
Private tiangan As String() = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"}
'十二地支
Private dizhi As String() = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"}
'十二生肖
Private shengxiao As String() = {"鼠", "牛", "虎", "免", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"}
'农历月
Private months As String() = {"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二(腊)"}
'农历日
Private days1 As String() = {"初", "十", "廿", "三"}
Private days As String() = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十"}
'返回农历年(天干 地支 生肖)
Private Function GetLunisolarYear(ByVal year As Integer) As String
GetLunisolarYear = ""
If (year > 3) Then
Dim tgIndex As Integer = (year - 4) Mod 10
Dim dzIndex As Integer = (year - 4) Mod 12
Return tiangan(tgIndex) & dizhi(dzIndex) & "[" & shengxiao(dzIndex) & "]"
End If
'无效的年份!
End Function
'返回生肖
Private Function GetShengXiao(ByVal sDateTime As Date) As String
Return shengxiao(cCalendarGetTerrestrialBranch(cCalendarGetSexagenaryYear(sDateTime)) - 1)
End Function
'返回农历月
Private Function GetLunisolarMonth(ByVal month As Integer) As String
GetLunisolarMonth = ""
If (month < 13 AndAlso month > 0) Then
Return months(month - 1)
End If
'无效的月份!
End Function
'返回农历日
Private Function GetLunisolarDay(ByVal day As Integer) As String
GetLunisolarDay = ""
If (day > 0 AndAlso day < 32) Then
If (day <> 20 AndAlso day <> 30) Then
Return StringConcat(days1((day - 1) \ 10), days((day - 1) Mod 10))
Else
Return StringConcat(days((day - 1) \ 10), days1(1))
End If
End If
'无效的日!
End Function
#End Region
代码改为:Private Sub Form_Click()Dim a, b, c, d As StringDim sum, aver As Longa = Val(InputBox("请输入第一个数"))
b = InputBox("请输入第二个数")
c = InputBox("请输入第三个数")
d = InputBox("请输入第四个数")
sum = a + b + c + d
aver = sum / 4
Print "所输入的4个数字分别是"; a, b, c, d
Print "4个数字的和为"; sum
Print "4个数字的平均值为"; averEnd Sub VB60下调试通过。
以上就是关于VB设计一个简单的小程序全部的内容,包括:VB设计一个简单的小程序、用vb制作了一个小程序 可怎样做个图标呢 插入icon总提示无效图片、用VB制作小程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)