vb.net Windows应用程序的用户定义功能 [英] user define function for vb.net windows application

查看:99
本文介绍了vb.net Windows应用程序的用户定义功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我正在vb.net Windows基本应用程序上工作,我必须在其中添加电子邮件地址,但它应该允许所有字母,数字和一些特殊(不是全部)字符,因此我想为用户定义功能.

Hi all
I am working on vb.net windows base application where I have to add email address but it should allow all alphabets ,numbers and some special(not all) character, so I want to make a user define function for that. can any one please help me how to do that?

推荐答案

尝试:
Private Shared validData As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 @.-_"
Private Shared Function IsValid(c As Char) As Boolean
    Return validData.Contains(c)
End Function
Private Shared Function ContainsAllValid(s As String) As Boolean
	For Each c As Char In s
		If Not IsValid(c) Then
			Return False
		End If
	Next
	Return True
End Function


您应该研究正则表达式. 此处 [这一个 [
You should research Regular Expressions. Here[^] are some Code Project Articles that you can start with. This one[^] looks like exactly what you are looking for.


这篇关于vb.net Windows应用程序的用户定义功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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