尝试使字符串变暗并获得“预期的语句结尾" [英] Trying to Dim a String and getting "Expected end of statement"

查看:97
本文介绍了尝试使字符串变暗并获得“预期的语句结尾"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的网站获得了一个新域名,以前是SomeOldWebsiteURL.com,现在是NewWebsite.com,下面是我放置在旧服务器上的重定向页面的HTML.

我的整个重定向页面如下.这必须在Classic ASP和VBScript中完成,我别无选择.

I got me a new domain name for my website and it used to be SomeOldWebsiteURL.com, now it''s NewWebsite.com and the below is the HTML for the redirect page I am placing on my old server.

My whole little redirect page is the following. This HAS to be done in Classic ASP and VBScript, I have no choice there.

<%
	Dim str As String = HttpContext.Current.Request.Url.Host

	If (String.Compare(HttpContext.Current.Request.Url.Host, "SomeOldWebsiteURL.com", True) = 0) Then
		Response.Redirect("index.asp")
	End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
</head>
<html>
<body>

</body>
</html>



当我尝试运行此命令时,在行Dim str As String上收到语句的预期结尾"错误.有人对我可能做错了什么建议吗?

提前谢谢!

Brian



When I try to run this, I get an "Expected end of statement" error on the line Dim str As String. Does anybody have a suggestion as to what I might be doing wrong?

Thanks in advance!

Brian

推荐答案

替换
Dim str As String = HttpContext.Current.Request.Url.Host




with

Dim str
str = HttpContext.Current.Request.Url.Host



顺便说一句,您实际上在剩余的代码中没有使用str.



BTW you actually are NOT using str in the remaining code.


应该反过来吗?

Shouldn''t it be the other way round?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
</head>
<html>
<body>

<%
	Dim str As String = HttpContext.Current.Request.Url.Host
 
	If (String.Compare(HttpContext.Current.Request.Url.Host, "SomeOldWebsiteURL.com", True) = 0) Then
		Response.Redirect("index.asp")
	End If
%> 

</body>
</html>


String.Compare调用中是否存在实际换行符?如果是这样,您将需要在下划线前加一个下划线,以使VB知道您将在下一行继续该语句.
Is that an actual line break in the String.Compare call? If so, you''ll need an underscore before the line break to let VB know that you''ll be continuing the statement on the next line.


这篇关于尝试使字符串变暗并获得“预期的语句结尾"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆