If Option1.Value = True Then
If Option2.Value = False Then
myRecord.Fields("SendTime").Value = Time_now.Text '发送时间为当前时间
End If
End If
If Option2.Value = True Then
If Option1.Value = False Then
myRecord.Fields("SendTime").Value = Time_scheduled.Text '自定义发送时间
End If
End If
If Option2.Value = True Then
If CDate(Time_now.Text) > CDate(Time_scheduled.Text) Then
MsgBox "时间输入有误,请重新输入!", vbExclamation, "注意"
Time_scheduled.SetFocus
Exit Sub
End If
End If
我在form中用了两个option按钮,来选择发送短信的时间,一个是当前时间,一个是自定义的时间,两个不能同时用。这段代码是不是有问题啊。
还有如何把这个功能写到modul中去,让别人用起来方便一些。我觉得那不是要有好几个参数吗?
对VB还不是很熟悉来做这个工作,真是死了很多脑细胞啊。唉。请大家帮帮忙。
If Option2.Value = False Then
myRecord.Fields("SendTime").Value = Time_now.Text '发送时间为当前时间
End If
End If
If Option2.Value = True Then
If Option1.Value = False Then
myRecord.Fields("SendTime").Value = Time_scheduled.Text '自定义发送时间
End If
End If
If Option2.Value = True Then
If CDate(Time_now.Text) > CDate(Time_scheduled.Text) Then
MsgBox "时间输入有误,请重新输入!", vbExclamation, "注意"
Time_scheduled.SetFocus
Exit Sub
End If
End If
我在form中用了两个option按钮,来选择发送短信的时间,一个是当前时间,一个是自定义的时间,两个不能同时用。这段代码是不是有问题啊。
还有如何把这个功能写到modul中去,让别人用起来方便一些。我觉得那不是要有好几个参数吗?
对VB还不是很熟悉来做这个工作,真是死了很多脑细胞啊。唉。请大家帮帮忙。
'SendSMS (Time_now.Text) 发送时间为当前时间
'SendSMS (Time_scheduled.Text) 自定义发送时间Public Function SendSMS(ByVal SendTime As String) As Long If Option1.Value = True Then
myRecord.Fields("SendTime").Value = SendTime 'Time_now.Text 发送时间为当前时间
SendSMS = 1
Else
If CDate(Time_now.Text) > CDate(SendTime) Then '这个判断自己改一下,如果是午夜就出问题了
MsgBox "时间输入有误,请重新输入!", vbExclamation, "注意"
Time_scheduled.SetFocus
SendSMS = 0
Exit Function
Else
myRecord.Fields("SendTime").Value = SendTime 'Time_scheduled.Text 自定义发送时间
SendSMS = 1
End If
End If
End Function
函数里对应换过来.
Option1
Option2
myRecord.Fields("SendTime").Value
Time_now.Text
Time_scheduled.Text
Time_scheduled.SetFocus
Option2 ……byval blnSelect1 as boolean
Time_now.Text ……byval strTimeNow as string
Time_scheduled.Text ……byval strTimeScheduled as string
myRecord.Fields("SendTime").Value ……如果函数内使用myRecord则不用,否则作为函数返回值
Time_scheduled.SetFocus ……Time_scheduled as textbox
If myoption = True Then
timetable = SendTime 'Time_now.Text 发送时间为当前时间
Else
If CDate(timenow) > CDate(SendTime) Then
MsgBox "时间输入有误,请重新输入!", vbExclamation, "注意"
'Time_scheduled.SetFocus
Exit Function
Else
timetable = SendTime 'Time_scheduled.Text 自定义发送时间
End If
End IfEnd Function调用时这样:
Call Timeoption(Text4.Text, Option1.Value, Text5.Text, timenow)可是不对啊,text5收不到东西 ,问题出在哪儿啊
If myoption = True Then
timetable = SendTime 'Time_now.Text 发送时间为当前时间
Else
If CDate(timenow) > CDate(SendTime) Then
MsgBox "时间输入有误,请重新输入!", vbExclamation, "注意"
'Time_scheduled.SetFocus
Exit Function
Else
timetable = SendTime 'Time_scheduled.Text 自定义发送时间
End If
End If End Function Text5.Text=Timeoption(Text4.Text, Option1.Value , timenow)
dim timetable as string
If myoption = True Then
timetable = SendTime 'Time_now.Text 发送时间为当前时间
Else
If CDate(timenow) > CDate(SendTime) Then
MsgBox "时间输入有误,请重新输入!", vbExclamation, "注意"
'Time_scheduled.SetFocus
Exit Function
Else
timetable = SendTime 'Time_scheduled.Text 自定义发送时间
End If
End If Timeoption=temetable
End Function Text5.Text=Timeoption(Text4.Text, Option1.Value , timenow)
If myoption = True Then
timetable = SendTime 'Time_now.Text 发送时间为当前时间
Else
If CDate(timenow) > CDate(SendTime) Then
MsgBox "时间输入有误,请重新输入!", vbExclamation, "注意"
'Time_scheduled.SetFocus
Exit Function
Else
timetable = SendTime 'Time_scheduled.Text 自定义发送时间
End If
End If End Function
调用时这样:
Call Timeoption(Text4.Text, Option1.Value, Text5.Text, timenow)