主题:  为什么这样:表达式不产生值?

truelove

职务:普通成员
等级:1
金币:0.0
发贴:128
#12004/12/22 11:36:05
<%@ Page Language="VB" %>
<script runat="server">

Sub Button1_Click(sender As Object, e As EventArgs)
if trim(upload_file.value)<>"" and trim(saveas_name.value)<>"" then
if check_filename(saveas_name.value) then '出错行,出错提示:表达式不产生值。
upload_file.postedfile.saveas(saveas_name.value)
response.write("上传文件成功"
saveas_name.value=""
else
response.write("error!"
end if
else
response.write("<script language=""javascript"">" & vbcrlf)
response.write("history.back(1)" & vbcrlf)
response.write("alert(""error!""" & vbcrlf)
response.write("</" & "script" & ">" )
end if
End Sub

sub check_filename(byval check_filename as string) as boolean
if right(check_filename,3)<>"jpg" or right(check_filename,3)<>"png" or right(check_filename,3)<>"gif" then
return false
else
return true
end if
end sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<table height="150" cellpadding="4" width="300" align="center" bgcolor="#cccccc">
<tbody>
<tr>
<td bgcolor="#eeeeee">
选择上传文件:
<input id="upload_file" type="file" runat="server" />
<br />
另存为文件名:&nbsp;
<input id="saveas_name" type="text" runat="server" />
<br />
<br />
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="上传文件"></asp:Button>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
#22004/12/22 11:40:49
Sub过程没有返回值
改用Function吧



truelove

职务:普通成员
等级:1
金币:0.0
发贴:128
#32004/12/22 12:30:45
谢谢allinhands,已经成功了。