海信家电”换帅 “ 高玉玲接替代慧忠出任新任董事长
2024-11-22
Public Class dogClass dog Private s_name As String Private s_color As Color Private s_age As Integer Public Sub New()Sub New() s_name = "塞北的雪" s_age = 22 s_color = System.Drawing.Color.Red End Sub Public Property Name()Property Name() As String Get Return s_name End Get Set(ByVal value As String) s_name = value End Set End Property Public Property Color()Property Color() As Color Get Return s_color End Get Set(ByVal value As Color) s_color = value End Set End Property Public Property Age()Property Age() As Integer Get Return s_age End Get Set(ByVal value As Integer) s_age = value End Set End Property Public Shared Operator +(ByVal a As dog, ByVal b As dog) Dim c As New dog c.Name = a.Name + b.Name c.Age = a.Age + b.Age c.Color = Color.FromArgb((a.Color.ToArgb + b.Color.ToArgb) / 2) Return c End Operator End Class |
Dim a As New dog Dim b As New dog() If a Is b Then MsgBox("True") Else MsgBox("False") End If b = a b.Name = "NorthSnow" If a Is b Then MsgBox("True") Else MsgBox("false") End If 'false 'true |
Dim sb As New System.Text.StringBuilder Dim m As New dog Dim n As New dog Dim c As dog m.Name = "NorthSnow" c = m + n sb.AppendLine() sb.Append(m.Name) sb.Append("--") sb.Append(m.Age) sb.Append("--") sb.Append(m.Color.ToArgb) sb.AppendLine() sb.Append(n.Name) sb.Append("--") sb.Append(n.Age) sb.Append("--") sb.Append(n.Color.ToArgb) sb.AppendLine() sb.Append(c.Name) sb.Append("--") sb.Append(c.Age) sb.Append("--") sb.Append(c.Color.ToArgb) MsgBox(sb.ToString) 'NorthSnow--22---65536 '塞北的雪--22---65536 'NorthSnow塞北的雪--44---65536 |
3、like操作符
like 操作符用于判断一个字符串与另外一个字符串是否匹配,大小写敏感。语法是:
Result=String like Pattern |
Dim a As String = "Northsnow,塞北的雪" Dim b As String = "Northsnow,塞北的雪" If a Like b Then MsgBox("true") Else MsgBox("false") End If b = "northsnow,塞北的雪" If a Like b Then MsgBox("true") Else MsgBox("false") End If 'true 'false |
Dim a As String = "Northsnow.123" Dim b As String = "*.###" MsgBox(a Like b) 'True #p#分页标题#e# a = "Northsnow.123" b = "[A-Z][a-z]*#" MsgBox(a Like b) 'True a = "Northsnow.123" b = "[A-Z][a-z]*[a-z]" MsgBox(a Like b) 'False a = "Northsnow.123" b = "[A-Z][a-z]*[0-9]" MsgBox(a Like b) 'True |
Dim a As New dog Dim b As New dog Dim c As Type c = a.GetType MsgBox(c.ToString) If TypeOf (a) Is VB1.Form7.dog Then MsgBox(True) End If 'vb1.Form7+dog 'True |
评论 {{userinfo.comments}}
{{child.content}}
{{question.question}}
提交