2014-11-06 6 views
-5

"opt1"이라는 단어가 입력되면 프로그램에서 generate username 하위 항목을 호출하는 프로그램을 만들어야합니다. 또는 "opt2"라는 단어가 입력되면 다른 하위 프로그램에서 프로그램이 호출됩니다 (관련이 있다고 생각하지 않으므로 아래 두 코드는이 하위 항목과 관련이 없습니다).사용자 선택에 따라 하위를 호출하는 방법은 무엇입니까?

Sub main() 

    Dim name As String 

    Console.WriteLine("What is your name?") 
    name = Console.ReadLine() 

    Console.WriteLine("Welcome " & name) 

    Call menu() 

End Sub  

Sub menu() 

    Dim opt1, opt2 As Integer 

    Console.WriteLine("Please select an action") 
    Console.WriteLine("1. Generate Username" & opt1) 
    Console.WriteLine("1. Generate Factorial Number" & opt2) 
    Console.ReadLine() 

    If opt1 Then 
     Call GenerateUsername(opt1)       
    End If             

End Sub      

필요한 정보를 놓친 경우 알려주십시오.

+0

'정보를 놓친 경우 ...'질문/문제가 발생하지 않았습니다. – Plutonix

+0

[Visual Studio의 통화 관련 문제] (http://stackoverflow.com/questions/26744130/) 비주얼 스튜디오에서 호출 기능을 가진 문제 발행) –

답변

1

"사용자 선택에 따라 하위를 호출하는 방법"제목에 질문이있는 경우 당신은 간단한 if-condition으로 그것을 할 수 있습니다. if typedtext = "opt1" then mysub1() else mysub2() endif. 당연히 더 많은 조건 또는 심지어 우리에게 사례 조건이있을 수 있습니다.

관련 문제