2011-10-11 51 views
1

做錯了在PHP中我用這什麼是我在ASP

'if(!f || !f2) 

現在我在把這個代碼ASP這樣

If Not f OR Not f2 Then 

,但它給出了一個錯誤我: -

Error Type: 
Microsoft VBScript runtime (0x800A01B6) 
Object doesn't support this property or method 

什麼,我現在能做的,我爲新手在ASP

+0

''||邏輯是*或*,不和。 –

+0

@Mark Byers :)對不起,我在這裏使用或之後,我給出了一個這樣的錯誤 – Johnson

+0

我的整個編碼在這裏http://pastebin.com/5Wqd6kk2 – Johnson

回答

0

您可能需要IsObject()

嘗試

If Not IsObject(f1) Or Not IsObject(f2) Then ... 
+1

如果'f1'或'f2'爲Nothing'IsObject'仍然返回true。 – AnthonyWJones

2

因爲ff2是對象,我認爲ASP是假設他們有哪些你想在

If Not f OR Not f2 Then 

測試默認屬性這就是爲什麼你該錯誤消息(例如,如果默認屬性爲Name,則實際上您正在測試If Not f.Name OR Not f2.Name Then)。

你可能想要做的就是測試,看看它們是無效的對象,您可以通過

If (f Is Nothing) OR (f2 Is Nothing) Then 
+0

如果f或f2還沒有被一個對象或Nothing設置爲特定的'這個代碼將會拋出一個錯誤。 – AnthonyWJones

+0

[他們有](http://pastebin.com/5Wqd6kk2) – 2011-10-11 08:59:50

1

做看起來你真正需要的是檢查是否存在或不是那些文件 - 傳統的ASP有不同於PHP的邏輯。

因此,嘗試使用此代碼來代替:

Dim fp1, f, f2 
Dim vid, vkey 
Dim enc, enc1, enc2 
set fp1 = Server.CreateObject("Scripting.FileSystemObject") 
If fp1.FileExists(vid_file) And fp1.FileExists(vkey_file) Then 
    set f = fp1.OpenTextFile(vid_file, 1, true) 
    set f2=fp1.OpenTextFile(vkey_file, 1, true) 
    vid = Trim(f.ReadLine) 
    vkey = Trim(f2.ReadLine) 
    f.Close 
    f2.Close 
    Set f = Nothing 
    Set f2 = Nothing 

    enc1 = hex_sha1(vid) 
    enc2 = hex_sha1(vkey) 
    enc = enc1 & enc2 
Else 
    Response.Write "Vendor authentication failed." 
End If 
相關問題