Click here to Skip to main content
15,440,277 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionthis is my code trying to deduct qty from tableproduct after sales Pin
Titus Miclus Afful7-Jul-22 0:11
MemberTitus Miclus Afful7-Jul-22 0:11 
AnswerRe: this is my code trying to deduct qty from tableproduct after sales Pin
Victor Nijegorodov7-Jul-22 0:31
MemberVictor Nijegorodov7-Jul-22 0:31 
GeneralRe: this is my code trying to deduct qty from tableproduct after sales Pin
jsc427-Jul-22 1:07
professionaljsc427-Jul-22 1:07 
GeneralRe: this is my code trying to deduct qty from tableproduct after sales Pin
Richard MacCutchan7-Jul-22 1:27
mveRichard MacCutchan7-Jul-22 1:27 
AnswerRe: this is my code trying to deduct qty from tableproduct after sales Pin
Richard Deeming7-Jul-22 2:08
mveRichard Deeming7-Jul-22 2:08 
QuestionRaise Event on another Form Pin
EngrImad21-Jun-22 5:01
MemberEngrImad21-Jun-22 5:01 
AnswerRe: Raise Event on another Form Pin
Dave Kreskowiak22-Jun-22 7:18
mveDave Kreskowiak22-Jun-22 7:18 
GeneralRe: Raise Event on another Form Pin
jsc426-Jul-22 6:23
professionaljsc426-Jul-22 6:23 
I've never got along with Events - they seem overly convoluted for simple tasks. My (also) rusty VB suggests that something like the following might do what you want (it is probably overkill)
VB
Public Class Form1
    Private f2 As Form2 = Nothing

    Sub F2IsActive(Enabled As Boolean)
        btnStartForm2.Enabled = Not Enabled
        btnDoSomethingOnForm2.Enabled = Enabled
        btnCloseForm2.Enabled = Enabled

        If Enabled Then
            If Not FormIsOpen(f2) Then  ' Needs to be opened
                f2 = New Form2()
                f2.Show()
            End If
        ElseIf FormIsOpen(f2) Then   ' Needs to be closed
            f2.Close()
            f2 = Nothing
        End If
    End Sub

    Private Sub btnStartForm2_Click(sender As Object, e As EventArgs) Handles btnStartForm2.Click
        F2IsActive(True)
    End Sub

    Private Sub btnDoSomethingOnForm2_Click(sender As Object, e As EventArgs) Handles btnDoSomethingOnForm2.Click
        If f2 Is Nothing Then
            MsgBox("You have to open Form2 first")
        ElseIf FormIsOpen(f2) Then
            f2.DoSomethingOnForm2()
        Else    ' No longer exists
            MsgBox("Form2 has disappeared")
            F2IsActive(False)
        End If
    End Sub

    Private Function FormIsOpen(formToFind As Form) As Boolean
        For Each testform As Form In Application.OpenForms
            If testform.Equals(formToFind) Then
                Return True
            End If
        Next

        Return False
    End Function

    Private Sub btnCloseForm2_Click(sender As Object, e As EventArgs) Handles btnCloseForm2.Click
        If Not FormIsOpen(f2) Then
            MsgBox("Form2 has already been closed")
        End If

        F2IsActive(False)
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        F2IsActive(False)
    End Sub
End Class

VB.NET
Public Class Form2
    Public Sub DoSomethingOnForm2()
        MsgBox("Hello from Form 1")
    End Sub
End Class


modified 6-Jul-22 12:42pm.

QuestionCopy Record(s) from 1 Database to Another Database with the same Tables Pin
crmfghtr20-Jun-22 16:42
Membercrmfghtr20-Jun-22 16:42 
AnswerRe: Copy Record(s) from 1 Database to Another Database with the same Tables Pin
Victor Nijegorodov20-Jun-22 20:24
MemberVictor Nijegorodov20-Jun-22 20:24 
QuestionGet Process Percentage Pin
EngrImad18-Jun-22 8:33
MemberEngrImad18-Jun-22 8:33 
AnswerRe: Get Process Percentage Pin
PIEBALDconsult18-Jun-22 8:35
professionalPIEBALDconsult18-Jun-22 8:35 
GeneralRe: Get Process Percentage Pin
EngrImad19-Jun-22 0:22
MemberEngrImad19-Jun-22 0:22 
GeneralRe: Get Process Percentage Pin
Dave Kreskowiak19-Jun-22 8:00
mveDave Kreskowiak19-Jun-22 8:00 
GeneralRe: Get Process Percentage Pin
EngrImad19-Jun-22 3:57
MemberEngrImad19-Jun-22 3:57 
AnswerRe: Get Process Percentage Pin
Richard Deeming19-Jun-22 21:41
mveRichard Deeming19-Jun-22 21:41 
AnswerRe: Get Process Percentage Pin
David Mujica22-Jun-22 3:42
MemberDavid Mujica22-Jun-22 3:42 
QuestionStrange behavior readline Pin
JR21214-Jun-22 1:05
MemberJR21214-Jun-22 1:05 
AnswerRe: Strange behavior readline Pin
Richard MacCutchan14-Jun-22 5:16
mveRichard MacCutchan14-Jun-22 5:16 
GeneralRe: Strange behavior readline Pin
JR21216-Jun-22 2:16
MemberJR21216-Jun-22 2:16 
AnswerRe: Strange behavior readline Pin
Alan N14-Jun-22 5:30
MemberAlan N14-Jun-22 5:30 
GeneralRe: Strange behavior readline Pin
JR21216-Jun-22 2:13
MemberJR21216-Jun-22 2:13 
QuestionDatabase relating entity having various data members Pin
lazy_dude12-Jun-22 20:17
Memberlazy_dude12-Jun-22 20:17 
AnswerRe: Database relating entity having various data members Pin
Richard Deeming12-Jun-22 21:26
mveRichard Deeming12-Jun-22 21:26 
GeneralRe: Database relating entity having various data members Pin
lazy_dude12-Jun-22 23:03
Memberlazy_dude12-Jun-22 23:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.