語句判斷時,如何不區分字串的大小寫

2021-06-04 18:29:00 字數 1378 閱讀 6354

第一:用if……end if 判斷

public class form1

private sub btnok_click(byval sender as system.object, byval e as system.eventargs) handles btnok.click

dim strname as string

strname = txtname.text

if string.compare(strname, "bryan", true) = 0 then  '選true時,不區分大小寫,字串匹配,返回0,選false時,區分大小寫,字串不匹配,返回-1

msgbox("hello, bryan!", vbokonly or msgboxstyle.information, "忽略大小寫試驗")

end if

end sub

private sub btnexit_click(byval sender as system.object, byval e as system.eventargs) handles btnexit.click

me.close()

end sub

end class

第二:用 select case 判斷

public class form1

private sub btnok_click(byval sender as system.object, byval e as system.eventargs) handles btnok.click

dim strname as string

strname = txtname.text

select case strname.toupper     '把字串轉換成大寫

case "a"

txtname.text = "madras yellow"

case "b"

txtname.text = "sea blue"

case "c"

txtname.text = "morning mist"

case "d"

txtname.text = "passionate purple"

case "e"

txtname.text = "red"

case else

txtname.text = "資料越界"

end select

end sub

private sub btnexit_click(byval sender as system.object, byval e as system.eventargs) handles btnexit.click

me.close()

end sub

end class

sql判斷字串包含字串語句

在sql中我判斷包含字串我們可使用很多方法,如like,replace,charindex函式都可實現我們要的功能,下面我來給各位介紹判斷字串包含字串sql語句。如果想從sql server中查詢包含某個關鍵字的東東,怎麼查詢呢?一般有兩個方法 1.用like 如下 複製 select from t...

ASP中的REPLACE函式如何不區分大小寫

函式 replace 功能 在字串中查詢,替代指定的字串.格式 replace strtobesearched,strsearchfor,strreplacewith start count compare 引數 strtobesearched是字串 strsearchfor是被查詢的子字串 str...

python 判斷區分字串是否都是英文 中文

b bilibili站 b.isalpha 中英混合不適用 true b.encode utf 8 isalpha false b.encode utf 8 b bilibili xe7 xab x99 word 1 如何再飄搖 res true for w in word 1 if not u4e...