कंप्यूटर प्रोग्रामिंग/स्ट्रिंग्स/विजुअल बेसिक .नेट
दिखावट
strings.vb
[सम्पादन | स्रोत सम्पादित करें]' This program splits a given comma-separated name into first and last name
' components and then displays the name.
Imports System
Public Module Strings
Sub Main
Dim Name As String
Dim First As String
Dim Last As String
Name = GetName()
Last = GetLast(Name)
First = GetFirst(Name)
DisplayName(First, Last)
End Sub
Function GetName() As String
Dim Name As String
Dim Index As Integer
Do
Console.WriteLine("Enter name (last, first):")
Name = Console.ReadLine()
Index = Name.IndexOf(",")
Loop While (Index < 0)
Return Name
End Function
Function GetLast(Name As String) As String
Dim Last As String
Dim Index As Integer
Index = Name.IndexOf(",")
If(Index < 0)
Last = ""
Else
Last = Name.Substring(0, Index)
End If
Return Last
End Function
Function GetFirst(Name As String) As String
Dim First As String
Dim Index As Integer
Index = name.IndexOf(",")
If(Index < 0)
First = ""
Else
First = Name.Substring(Index + 1, Name.Length - Index - 1)
First = First.Trim()
End If
Return First
End Function
Sub DisplayName(First As string, Last As string)
Console.WriteLine("Hello " + first + " " + last + "!")
End Sub
End Module
कोशिश करो
[सम्पादन | स्रोत सम्पादित करें]निम्न कोड मुफ्त ऑनलाइन विकास के वातावरण में से एक में ऊपर कॉपी और पेस्ट करो या अपने खुद के कम्पाइलर/इंटरप्रेटर/आईडीई का उपयोग करें।