好的,所以任务是
1) 使用各种程序编写程序来执行下列操作。使用委托调用这些过程。确保记录您的程序并让程序打印描述性文本以及 b 中的数字。和 c。 a) 以相反的字序打印文本字符串。 b) 打印字符串中的字符数。 c) 打印字符串中的字数。
我尝试了以下代码,但 AllGreets.DynamicInvoke 出现异常。我该怎么做才能解决这个问题?
我不是一个程序员,参加这门课并不是我做过的最好的选择,但现在我必须完成它。因为已经付钱了。
Module Module1
Sub Main()
Dim part1 As GreetingDelegate
Dim part2 As GreetingDelegate
Dim part3 As GreetingDelegate
Dim part4 As GreetingDelegate
part1 = AddressOf greating
part2 = AddressOf greatingchar
part3 = AddressOf reverse
part4 = AddressOf number
Dim AllGreets As GreetingDelegate = _
[Delegate].Combine(part1, part2, part3, part4)
AllGreets.DynamicInvoke()
End Sub
Public Delegate Sub GreetingDelegate(ByVal MsgString As String)
' What the greating is
Public Sub greating()
Console.WriteLine("The greating is Hi how are you?")
System.Console.WriteLine("press enter")
Console.ReadLine()
End Sub
' Number of char in string
Public Sub greatingchar()
Dim thing As Long
thing = Len("Hi how are you?")
System.Console.WriteLine("There is")
System.Console.WriteLine(thing)
System.Console.WriteLine("characters in this greating")
System.Console.WriteLine("press enter")
Console.ReadLine()
End Sub
Public Sub reverse()
' string in reverse
Dim t As String
t = StrReverse$("Visual Basic")
System.Console.WriteLine(t)
System.Console.WriteLine("press enter")
System.Console.ReadLine()
End Sub
Public Sub number()
'number of word in string
Dim count As Long
Dim text As String
text = "Hi how are you?"
count = text.Split(" ").Length
System.Console.WriteLine(count)
System.Console.WriteLine("press enter")
System.Console.ReadLine()
End Sub
End Module