我得到的小语法错误 [英] little syntax error i got

查看:73
本文介绍了我得到的小语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我尝试制作的这段代码有点麻烦.
我正在尝试拥有(如果是管理员的话)之类的东西
只有我要使用用户名,而不要使用管理员配置文件类型.

用户名是(sysadmin,管理员,备份.)

这是代码:

hello,
I am having a little trouble with this code I am trying to make.
I am trying to have like (if admin then do this) thing
only I would like to use usernames and not the administrator profile type.

The usernames are (sysadmin, administrator, backup.)

Here is the code:

If (LCase(Environment.UserName)) = (CStr("sysadmin") Or CStr("administrator") Or CStr("backup")) Then
    MessageBox.Show("You are an administrator")
Else
    MessageBox.Show("You are not an authorised user!")
End If



我得到的错误是:
从字符串"sysadmin"到类型"Double"的转换无效.

我想我需要尝试将用户名"sysadmin"转换为字符串或其他内容.

谁能告诉我正确的方法.


感谢



the error I am getting is:
Conversion from string "sysadmin" to type ''Double'' is not valid.

I think I need to try to convert my username "sysadmin" to string or somthing.

Can any one show me the right way of doing this.


thanks

推荐答案

您好,请使用下面的代码

Hi, use below code

If (LCase(Environment.UserName) = "sysadmin" Or LCase(Environment.UserName) = CStr("administrator") Or  LCase(Environment.UserName) = "backup") Then
            MessageBox.Show("You are an administrator")
        Else
            MessageBox.Show("You are not an authorised user!")
        End If


这篇关于我得到的小语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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