Tuesday, April 25, 2023

VB.NET MOVING TEXT/CHANGE FONT COLOR AND BACKGROUND ALSO CHANGE FONT STYLE

 HI THERE,IM HERE TO SHOW AND SHARE A LITTLE CODES ON HOW LABEL TEXT RUNNING IN YOUR PROJECT FORM.

ALSO ON THIS CODES INCLUDING CHANGE FONT COLOR AND BACKGROUND AND ALSO YOU CAN CHANGE FONT STYLE.





CODES:

Public Class Form1




    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Static i As Integer = 721
        lblText.SetBounds(i, 47, 223, 45)
        i = i - 1
        If i = -2000 Then
            i = 721
        End If


    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Timer1.Start()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        lblText.Text = TextBox1.Text
    End Sub

    Private Sub TextColorToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TextColorToolStripMenuItem.Click
        ColorDialog1.ShowDialog()
        lblText.ForeColor = ColorDialog1.Color
    End Sub

    Private Sub BackgroundColorToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BackgroundColorToolStripMenuItem.Click
        ColorDialog2.ShowDialog()
        Me.BackColor = ColorDialog2.Color
    End Sub

    Private Sub FontChangeToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FontChangeToolStripMenuItem.Click
        FontDialog1.ShowDialog()
        lblText.Font = FontDialog1.Font
    End Sub
End Class


PLEASE DONT FORGET TO CLICK ANY LINK ADVERTISE HERE TO SHOW YOUR SUPPORT MY WEBSITE AND PLEASE SUBSCRIBE/LIKE AND SHARE MY LITTLE CHANNEL TO GET UPDATE ON PROGRAMMING.

FOR SOMEONE WANT TO SEND A LITTLE DONATION,HERE IS MY GCASH:

09755 907 279


THANKS!

Monday, April 24, 2023

VB.NET STUDENT GRADES CALCULATOR (1)

 HI GUYS,NOW I WILL SHARE A SIMPLE CODES THAT CAN CALCULATE

THE STUDENT GRADES USING VB.NET.








CODES:


PUT THIS CODES UNDER THE BUTTON CLICK EVENT


     txtAverage.Text = (Val(txtFilipino.Text) + Val(txtScience.Text) + Val(txtMath.Text) + Val(txtEnglish.Text) + Val(txtComputer.Text)) / 5


Sunday, April 23, 2023

VB.NET MATH QUIZ GENERATOR SOURCE CODE

 

HI GUYS,NOW I WILL SHARE A SIMPLE CODES FOR MAKING YOUR OWN MATH QUIZ GENERATOR.










THE CODES:





Imports Microsoft.CSharp.CSharpCodeProvider
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Text.RegularExpressions
Imports System.Threading
Imports System.Windows.Forms
Public Class Form1


    Private flag As Byte

    Private quizgenerate As String()

    Private inquiz As Boolean
    Protected qo As Boolean

    Private Sub okbutton_Click(sender As Object, e As EventArgs) Handles okbutton.Click
        If Convert.ToInt32(Me.txtmax.Text) < 10 Then
            Me.txtmax.Text = "10"
            Me.maxsoal.Refresh()
        End If

        If Convert.ToInt32(Me.txtnum.Text) < 10 Then
            Me.txtnum.Text = "10"
            Me.ttsoal.Refresh()
        End If

        Me.okbutton.Enabled = False
        Me.okbutton.Refresh()
        Me.Cursor = Cursors.WaitCursor
        Me.pb.Value = 0
        Me.pb.Refresh()
        Me.label4.Text = "0%"
        Me.label4.Refresh()
        Me.richTextBox1.Clear()
        Me.dstr.Visible = True
        Me.dstr.Refresh()
        Me.dstr.Visible = True
        Me.dstr.Refresh()

        If Me.rb1.Checked Then
            Me.flag = 0
        End If

        If Me.rb2.Checked Then
            Me.flag = 1
        End If

        Me.inquiz = False
        Thread.Sleep(100)
        Me.quizgenerate = New String(Convert.ToInt32(Me.ttsoal.Text) - 1) {}
        Me.bw.RunWorkerAsync()
    End Sub

    Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click
        Try
            Clipboard.Clear()
            Clipboard.SetText(Me.richTextBox1.Text)
        Catch
        End Try
    End Sub

    Private Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles bw.DoWork
        If Not Me.inquiz Then
            Me.inquiz = True

            If Me.flag = 1 Then
                Me.rsltderet(Me.generatepatern(100))
            End If

            If Me.flag = 0 Then
                Me.prgs()
            End If
        End If
    End Sub
    Private Function generatepatern(ByVal rslt As Integer) As String()
        Dim strArray As String() = New String(rslt - 1) {}
        Dim index As Integer = 0

        While True
            Dim str As String

            While True

                If index >= rslt Then
                    Return strArray
                End If

                strArray(index) = ""
                str = ""
                Dim flag As Boolean = False

                While True

                    If flag Then
                        Exit While
                    End If

                    str = ""
                    Dim num2 As Integer = 0

                    While True

                        If num2 < 3 Then
                            Thread.Sleep(&H10)
                            Dim random As Random = Nothing
                            random = New Random()
                            Dim num3 As Integer = random.[Next](1, 5)
                            Thread.Sleep(&H10)
                            Dim random1 As Random = New Random()
                            Dim num6 As Integer = random.[Next](3) Mod 3

                            Select Case num6
                                Case 0
                                    str = str & "+" & num3.ToString() & " "
                                Case 1
                                    str = str & "-" & num3.ToString() & " "
                                Case 2
                                    str = str & "x" & num3.ToString() & " "
                                Case Else
                            End Select

                            num2 += 1
                            Continue While
                        End If

                        Dim flag2 As Boolean = False
                        Dim num5 As Integer = 0

                        While True

                            If num5 < strArray.Length Then

                                If Not String.IsNullOrEmpty(strArray(num5)) AndAlso (strArray(num5).Trim() = str.Trim()) Then
                                    flag2 = True
                                ElseIf Not String.IsNullOrEmpty(strArray(num5)) Then
                                    num5 += 1
                                    Continue While
                                End If
                            End If

                            If Not flag2 Then
                                flag = True
                            End If

                            Exit While
                        End While

                        Exit While
                    End While
                End While

                Exit While
            End While

            strArray(index) = str.Trim()
            index += 1
        End While
    End Function

    Private Sub prgs()
        Try
            Dim str As String
            Dim method As MethodInvoker = Nothing
            Dim maxValue As Integer = Convert.ToInt32(Me.txtmax.Text)
            Dim rslt As Integer = Convert.ToInt32(Me.txtnum.Text)
            Dim hl As String = ""
            Dim num2 As Single = 0F
            Dim hlp As String() = New String(rslt - 1) {}
            Dim invoker As MethodInvoker = Nothing
            Dim m As Integer = 0
            GoTo TR_002C
TR_000A:
            hlp(m) = str & "=" & num2.ToString()

            If MyBase.InvokeRequired Then

                If invoker Is Nothing Then
                    invoker = Function()
                                  Dim num As Single = (Single.Parse((m + 1).ToString()) / Single.Parse(rslt.ToString())) * 100.0F
                                  Me.pb.Value = Convert.ToInt32(num)
                                  Me.label4.Text = Convert.ToInt32(num).ToString() & "%"
                                  Me.label4.Refresh()
                                  Me.pb.Refresh()
                              End Function
                End If

                Me.Invoke(invoker)
            End If

            m += 1
TR_002C:

            While True

                If m < rslt Then
                    Dim flag As Boolean = False
                    str = ""

                    While True

                        If flag Then
                            Exit While
                        End If

                        Thread.Sleep(&H10)
                        Dim random As Random = New Random()
                        num2 = 0F + random.[Next](1, maxValue)
                        str = num2.ToString()
                        Thread.Sleep(&H10)
                        Dim num3 As Integer = random.[Next](1, 4)
                        Dim num4 As Integer = 0

                        While True

                            If num4 < num3 Then
                                Thread.Sleep(&H10)
                                Dim num5 As Single = New Random().[Next](1, maxValue)
                                Thread.Sleep(&H10)
                                Dim num6 As Integer = New Random().[Next](4)
                                Dim num10 As Integer = num6 Mod 4

                                Select Case num10
                                    Case 0
                                        num2 += Single.Parse(num5.ToString())
                                        str = str & "+" & num5.ToString()
                                    Case 1
                                        num2 -= Single.Parse(num5.ToString())
                                        str = str & "-" & num5.ToString()
                                    Case 2

                                        str = str & "x" & num5.ToString()
                                    Case 3

                                        str = str & "/" & num5.ToString()
                                    Case Else
                                End Select

                                num4 += 1
                                Continue While
                            End If

                            Dim str2 As String = num2.ToString().Substring(0, 1)
                            Dim index As Integer = num2.ToString().IndexOf(","c)
                            Dim flag2 As Boolean = False

                            If index > -1 Then
                                Dim str3 As String = num2.ToString().Substring(index + ",".Length)

                                If str3.Contains("9") OrElse (str3.Contains("8") OrElse (str3.Contains("7") OrElse (str3.Contains("6") OrElse (str3.Contains("5") OrElse (str3.Contains("4") OrElse (str3.Contains("3") OrElse (str3.Contains("2") OrElse str3.Contains("1")))))))) Then
                                    flag2 = True
                                End If
                            End If

                            If num2.ToString().ToLower() = "infinity".ToLower() Then
                                flag2 = True
                            End If

                            If num2.ToString().ToLower() = "nan".ToLower() Then
                                flag2 = True
                            End If

                            Dim str4 As String = str & "=" & num2.ToString()
                            Dim num9 As Integer = 0

                            While True

                                If num9 < hlp.Length Then

                                    If Not String.IsNullOrEmpty(hlp(num9)) AndAlso (hlp(num9) = str4) Then
                                        flag2 = True
                                    ElseIf Not String.IsNullOrEmpty(hlp(num9)) Then
                                        num9 += 1
                                        Continue While
                                    End If
                                End If

                                If (str2 <> "-") AndAlso Not flag2 Then
                                    flag = True
                                End If

                                Exit While
                            End While

                            Exit While
                        End While
                    End While
                Else

                    If MyBase.InvokeRequired Then

                        If method Is Nothing Then
                            method = Function()
                                         Dim index As Integer = 0

                                         While index < rslt
                                             Dim separator As Char() = New Char() {"+"c, "-"c, "x"c, "/"c, "="c}
                                             Dim strArray As String() = hlp(index).Split(separator)
                                             Dim chArray2 As Char() = New Char() {"0"c, "1"c, "2"c, "3"c, "4"c, "5"c, "6"c, "7"c, "8"c, "9"c}
                                             Dim strArray2 As String() = hlp(index).Split(chArray2, StringSplitOptions.RemoveEmptyEntries)
                                             Thread.Sleep(&H10)
                                             Dim num3 As Integer = New Random().[Next](strArray.Length) Mod strArray.Length
                                             Dim _str As String = strArray(num3)
                                             strArray(num3) = "?"
                                             hlp(index) = ""
                                             Dim num4 As Integer = 0

                                             While True
                                                 Dim _strArray3 As String()
                                                 Dim ptr As IntPtr
                                                 If CheckBox1.Checked Then
                                                     If num4 >= strArray.Length Then
                                                         Dim strArray5 As String() = New String() {hl, "#MATH~", hlp(index).Trim(), "|", _str.ToString() + vbNewLine}
                                                         hl = String.Concat(strArray5)
                                                         Me.richTextBox1.Text = (hl)
                                                         Me.richTextBox1.Refresh()
                                                         index += 1
                                                         Exit While
                                                     End If
                                                 Else
                                                     If num4 >= strArray.Length Then
                                                         Dim strArray5 As String() = New String() {hl, "#MATH~", hlp(index).Trim(), "|", _str.ToString()}
                                                         hl = String.Concat(strArray5)
                                                         Me.richTextBox1.Text = (hl)
                                                         Me.richTextBox1.Refresh()
                                                         index += 1
                                                         Exit While
                                                     End If
                                                 End If
                                                 Dim str2 As String = ""

                                                 If num4 < strArray2.Length Then
                                                     str2 = strArray2(num4).ToString()
                                                 End If

                                                 Dim strArray4 As String() = New String() {strArray(num4), " ", str2, " "}
                                                 CSharpImpl.__Assign(_strArray3, hlp)(CInt((CSharpImpl.__Assign(ptr, CType(index, IntPtr))))) = String.Concat(strArray4)
                                                 num4 += 1
                                             End While
                                         End While

                                         Me.Cursor = Cursors.[Default]
                                         Me.okbutton.Enabled = True
                                     End Function
                        End If

                        Me.Invoke(method)
                    End If

                    Return
                End If

                Exit While
            End While

            GoTo TR_000A
        Catch exception1 As Exception
            Dim message As String = exception1.Message
        End Try
    End Sub

    Private Sub rsltderet(ByVal ptrn As String())
        Try
            Dim str As String
            Dim method As MethodInvoker = Nothing
            Dim invoker2 As MethodInvoker = Nothing
            Dim invoker3 As MethodInvoker = Nothing
            Dim maxValue As Integer = Convert.ToInt32(Me.maxsoal.Text)
            Dim num2 As Integer = Convert.ToInt32(Me.ttsoal.Text)
            Dim hasil As String = ""
            Dim num3 As Integer = 0
            Dim strArray As String() = New String(num2 - 1) {}
            Dim bb As Integer = num2 * 2
            Dim ckl As Integer = 0
            Dim index As Integer = 0
            GoTo TR_0044
TR_001D:
            strArray(index) = str

            If MyBase.InvokeRequired Then

                If method Is Nothing Then
                    method = Function()
                                 Dim num As Single = (Single.Parse((ckl + 1).ToString()) / Single.Parse(bb.ToString())) * 50.0F
                                 Me.pb.Value = Convert.ToInt32(num)
                                 Me.label4.Text = Convert.ToInt32(num).ToString() & "%"
                                 Me.label4.Refresh()
                                 Me.pb.Refresh()
                             End Function
                End If

                Me.Invoke(method)
            End If

            ckl += 1
            index += 1
TR_0044:

            While True

                If index < num2 Then
                    Dim flag As Boolean = False
                    str = ""

                    While True

                        If flag Then
                            Exit While
                        End If

                        Thread.Sleep(&H10)
                        Dim random As Random = New Random()
                        num3 = 0 + random.[Next](maxValue)
                        str = num3.ToString()
                        Thread.Sleep(&H10)
                        Dim num5 As Integer = New Random().[Next](ptrn.Length) Mod ptrn.Length
                        Thread.Sleep(&H10)
                        Dim num6 As Integer = New Random().[Next](2, 4)
                        Dim separator As Char() = New Char() {" "c}
                        Dim strArray2 As String() = ptrn(num5).Split(separator, StringSplitOptions.RemoveEmptyEntries)
                        Dim num7 As Integer = 0

                        While True

                            If num7 < num6 Then
                                Dim num8 As Integer = 0

                                While True

                                    If num8 >= strArray2.Length Then
                                        num7 += 1
                                        Exit While
                                    End If

                                    Dim str2 As String = strArray2(num8).Trim().Substring(0, 1)
                                    Dim num9 As Integer = Convert.ToInt32(strArray2(num8).Trim().Substring(1))
                                    Dim str5 As String = str2

                                    If str5 IsNot Nothing Then

                                        If str5 = "+" Then
                                            num3 += num9
                                            str = str & " " & num3.ToString()
                                        ElseIf str5 = "-" Then
                                            num3 -= num9
                                            str = str & " " & num3.ToString()
                                        ElseIf str5 = "x" Then
                                            str = str & " " & (num3 * num9).ToString()
                                        End If
                                    End If

                                    num8 += 1
                                End While

                                Continue While
                            End If

                            Dim flag2 As Boolean = False
                            Dim str3 As String = str
                            Dim num10 As Integer = 0

                            While True

                                If num10 < strArray.Length Then

                                    If Not String.IsNullOrEmpty(strArray(num10)) AndAlso (strArray(num10) = str3) Then
                                        flag2 = True
                                    ElseIf Not String.IsNullOrEmpty(strArray(num10)) Then
                                        num10 += 1
                                        Continue While
                                    End If
                                End If

                                Dim strArray3 As String() = str.Split(New Char() {" "c})
                                Dim num11 As Integer = 0
                                Dim num12 As Integer = 0

                                While True

                                    If num12 < strArray3.Length Then

                                        If strArray3(num12).Trim().Substring(0, 1) <> "-" Then
                                            num11 += 1
                                        End If

                                        num12 += 1
                                        Continue While
                                    End If

                                    If num11 < 3 Then
                                        flag2 = True
                                    End If

                                    If Not flag2 Then
                                        flag = True
                                    End If

                                    Exit While
                                End While

                                Exit While
                            End While

                            Exit While
                        End While
                    End While
                Else
                    Dim num13 As Integer = 0

                    While True

                        If num13 >= num2 Then

                            If MyBase.InvokeRequired Then

                                If invoker3 Is Nothing Then
                                    invoker3 = Function()
                                                   If CheckBox1.Checked Then
                                                       For i As Integer = 0 To Me.quizgenerate.Length - 1
                                                           hasil = hasil & Me.quizgenerate(i) + vbNewLine
                                                           Me.richTextBox1.Text = hasil
                                                           Me.richTextBox1.Refresh()
                                                       Next
                                                   Else
                                                       For i As Integer = 0 To Me.quizgenerate.Length - 1
                                                           hasil = hasil & Me.quizgenerate(i)
                                                           Me.richTextBox1.Text = hasil
                                                           Me.richTextBox1.Refresh()
                                                       Next
                                                   End If
                                                   Me.Cursor = Cursors.[Default]
                                                   Me.okbutton.Enabled = True
                                                   Me.okbutton.Refresh()
                                                   Me.dstr.Visible = False
                                                   Me.dstr.Refresh()
                                                   Thread.Sleep(100)
                                               End Function
                                End If

                                Me.Invoke(invoker3)
                            End If

                            Exit While
                        End If

                        Dim separator As Char() = New Char() {" "c}
                        Dim strArray4 As String() = strArray(num13).Split(separator, StringSplitOptions.RemoveEmptyEntries)
                        Dim flag3 As Boolean = False
                        Dim str4 As String = ""

                        While True

                            If Not flag3 Then
                                Thread.Sleep(&H10)
                                Dim num14 As Integer = New Random().[Next](strArray4.Length) Mod strArray4.Length

                                If strArray4(num14).Trim().Substring(0, 1) = "-" Then
                                    Continue While
                                End If

                                str4 = strArray4(num14)
                                strArray4(num14) = "?"
                                flag3 = True
                            End If

                            strArray(num13) = ""
                            Dim num15 As Integer = 0

                            While True
                                Dim strArray5 As String()
                                Dim ptr As IntPtr

                                If num15 >= strArray4.Length Then
                                    Me.quizgenerate(num13) = "#deret~" & strArray(num13).Trim() & "|" & str4.ToString()

                                    If MyBase.InvokeRequired Then

                                        If invoker2 Is Nothing Then
                                            invoker2 = Function()
                                                           Dim num As Single = (Single.Parse((ckl + 1).ToString()) / Single.Parse(bb.ToString())) * 100.0F
                                                           Me.pb.Value = Convert.ToInt32(num)
                                                           Me.label4.Text = Convert.ToInt32(num).ToString() & "%"
                                                           Me.label4.Refresh()
                                                           Me.pb.Refresh()
                                                       End Function
                                        End If

                                        Me.Invoke(invoker2)
                                    End If

                                    ckl += 1
                                    num13 += 1
                                    Exit While
                                End If
                                CSharpImpl.__Assign(strArray5, strArray)(CInt((CSharpImpl.__Assign(ptr, CType(num13, IntPtr))))) = strArray5(CInt(ptr)) & strArray4(num15) & " "
                                num15 += 1
                            End While
                            Exit While
                        End While
                    End While

                    Return
                End If

                Exit While
            End While

            GoTo TR_001D
        Catch exception1 As Exception
            Dim message As String = exception1.Message
        End Try
    End Sub
    Private Sub bw_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bw.RunWorkerCompleted
        Me.Cursor = Cursors.[Default]
    End Sub
    Private Sub rfrsh(ByVal e As KeyPressEventArgs)
        If Not Regex.IsMatch(e.KeyChar.ToString(), "\d+") Then
            e.Handled = True
        End If
    End Sub
    Private Sub txtmax_KeyPress(sender As Object, e As KeyPressEventArgs) Handles maxsoal.KeyPress
        Me.rfrsh(e)
    End Sub





End Class









PLEASE DONT FORGET TO SUPPORT MY WEBSITE AND MY LITTLE YOUTUBE CHANNEL BY SHARE/LIKES AND SUBSCRIBE.



THANKS!