Vb Net Lab Programs For Bca Students Fix Direct
Your nested loops are off by one. Use this standard bubble sort fix:
' Correct Procedure Sub Swap(ByRef x As Integer, ByRef y As Integer) Dim temp As Integer temp = x x = y y = temp End Sub ' Button Click Event Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim num1 As Integer = Val(TextBox1.Text) Dim num2 As Integer = Val(TextBox2.Text) Swap(num1, num2) ' Now this modifies the original variables TextBox1.Text = num1 TextBox2.Text = num2 End Sub vb net lab programs for bca students fix
Normalize the string by converting to lowercase and removing spaces/punctuation. Your nested loops are off by one
You must use ByRef (not ByVal ) in your procedure. Function IsPalindrome(ByVal input As String) As Boolean Dim
Function IsPalindrome(ByVal input As String) As Boolean Dim clean As String = input.Replace(" ", "").ToLower() Dim reversed As String = StrReverse(clean) Return clean = reversed End Function Always ask the examiner if case matters. If not specified, force ToLower() . 4. Program: Student Grade Calculator (If-Else If Ladder) Common Problem: The program always shows "Grade F" or skips conditions.
If marks >= 90 Then Grade = "A" ElseIf marks >= 80 AndAlso marks < 90 Then Grade = "B" ElseIf marks >= 70 Then Grade = "C" Else Grade = "F" End If Common Problem: The array outputs in the same order as input.
ByVal sends a copy ; ByRef sends the memory address . 3. Program: Palindrome Checker (String & Integer) Common Problem: "Madam" returns false, but "radar" returns true. Case sensitivity fails.
