日期:2014-05-17  浏览次数:20865 次

关于程序返回值的问题
Function   CreateAppPool(strName)
Dim   Entries
On   Error   Resume   Next  
Err.Clear
      Set   ObjAppPoolsExist   =   GetObject( "IIS:// "&Get_Computer(1)& "/W3SVC/AppPools ")
      Set   ObjAppPoolsExist   =   ObjAppPoolsExist.Create( "IIsApplicationPool ",strName)
If   Err.number   <>   0   Then '应用池存在
'判断应用池有多少个
Entries=Examine(strName,1)
if Entries> =ApplyAmount   then
Digit=Right(strName,1)
if   not   yk_shu(Digit)   then
call   CreateAppPool(strName& "_1 ")
Exit   Function
else
strName=replace(strName,Digit,Digit+1)
call   CreateAppPool(strName)
Exit   Function
end   if
else
CreateAppPool=strName
Set   ObjAppPoolsExist   =   Nothing
Exit   Function
end   if
Else
ObjAppPoolsExist.AppPoolIdentityType   =   2  
ObjAppPoolsExist.SetInfo  
If   err.Number   =   0   Then
                                                      'CreateAppPool=strName返回放在这里也有问题返回不到值
'response.Write   "应用程序 "&strName& "创建成功! "
Else  
'response.Write   "应用程序 "&strName& "创建失败! "
End   If  
End   If
Set   ObjAppPoolsExist   =   Nothing
response.Write   "---- "&strName& "---- <br> "
CreateAppPool=strName
End   Function


response.Write   "---- "&strName& "---- <br> "程序运行的时候这里面有值
就是返回CreateAppPool=strName这里取不到值
参数调用CreateAppPool( "a ")
第一次运行能正确返回a
第2次同样的参数应该返回a_1但是就是返回不到值~!请问我那里写错了

------解决方案--------------------
应该是这样的吧

Function CreateAppPool(strName)
Dim Entries
On Error Resume Next
Err.Clear
Set ObjAppPoolsExist = GetObject( "IIS:// "&Get_Computer(1)& "/W3SVC/AppPools ")
Set ObjAppPoolsExist = ObjAppPoolsExist.Create( "IIsApplicationPool ",strName)
If Err.number <> 0 Then '应用池存在
'判断应用池有多少个
Entries=Examine(strName,1)
if Entries> =ApplyAmount then
Digit=Right(strName,1)
if not yk_shu(Digit) then
CreateAppPool = CreateAppPool(strName& "_1 ")
Exit Function
else
strName=replace(strName,Digit,Digit+1)
CreateAppPool = CreateAppPool(strName)
Exit Function
end if
else
CreateAppPool=strName
Set ObjAppPoolsExist = Nothing
Exit Function
end if
Else
ObjAppPoolsExist.AppPoolIdentityType = 2
ObjAppPoolsExist.SetInfo
If err.Number = 0 Then
'CreateAppPool=strName返回放在这里也有问题返回不到值
'response.Write "应用程序 "&strName& "创建成功! "
Else
'response.Write "应用程序 "&strName& "创建失败! "
End If
End If
Set ObjAppPoolsExist = Nothing
response.Write "---- "&strName& "---- <br> "
CreateAppPool=strName
End Function


中间