Allowing User To Change Start-Up Form (User Control) - controls

I am developing a software in which a user can control and monitor their system. As a default, a welcome screen pops up and welcomes the user. However, I want them to have the option to skip it.
Here is the code I am trying to work with as I found on another form, but no luck. Any solutions?
Link to Abel Software Website
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If CheckBox1.Checked = True Then
My.Application.MainForm = Form1
End If
Form1.Show()
Me.Close()
End Sub
The Welcome Screen

Related

How to delay the LostFocus Event in VB6

I'm having an issue with a process that involves the LostFocus event.
When the cursor loses focus from a particular textbox, I'm simply putting the focus back into that box.
My issue is removing focus long enough for the user to click a log out button. Is there a way to intercept the LostFocus event long enough to allow the user to click the log out button?
Obviously I don't know the big picture here. But keeping only with what you said, the following does the trick. Effectively the event is delayed briefly, allowing the button to be clicked:
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Text1_LostFocus()
Sleep 100
DoEvents
Text1.SetFocus
End Sub
With a combination of a Timer and another control that is outside of the borders of your form, you can achieve this.
Private Sub Text1_LostFocus()
Combo1.SetFocus
ReturnFocusTimer.Enabled = True
End Sub
Private Sub ReturnFocusTimer_Timer()
ReturnFocusTimer.Enabled = False
Text1.SetFocus
End Sub
In this example Combo1 is positioned beyond the bottom of the form. You can control the ReturnFocusTimer interval to however long you need.

How can I change the text of a label while running in visual basic?

Right now my label is having a text "hello", how can I change it to "world" by a button click while running in Visual Basic.
Write a button click event. It can be done either manually or by double clocking on the button in the designer view:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
End If
Notice the end of it how it says "Button1.Click". Change Button1 to whatever the name of your button is.
Now add the code to change your textbox's text:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Textbox1.text = "world"
End If
Again note the name of the textbox and change "Textbox1" to whatever your textbox is named.
I assume you are new to learning how to program since what you asked is pretty basic. Try to find some tutorials online to help you better understand things. In this case you should look up and understand how control properties work along with events.

How to prevent controls from flickering when loading in VB.net?

I am currently facing a problem with my current windows application. This is the video of my problem.
Flickering Problem
As you can see, every time I click some buttons and when it loads the controls (tab controls and panel), they were flickering around and it seem to look annoying. How can I get rid of this? I already tried to set the DoubleBuffer to true but still not working. Any help?
I also do the suspendlayout() and resumelayout() inside the load event but still not working. Or maybe because I have coded it wrongly. This is my code:
Private Sub frmAdminPanel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblUser.Text = currentUser
Me.pnlOverview.SuspendLayout()
Me.tabPayment.Visible = False
Me.tabClientReporting.Visible = False
Me.btnNewEntry.Visible = False
Me.btnPayment.Visible = False
setOverview()
Me.pnlOverview.Visible = True
Me.pnlOverview.ResumeLayout()
End Sub
If there is any code in Load event of the form that manipulates the UI then you should try using SuspendLayout() and ResumeLayout() to prevent flickering.
Instead of using SuspendLayout and ResumeLayout, try using BeginUpdate and EndUpdate.

Visual Basic 6: how to make application visible in taskbar?

I've set property ShowInTaskBar to true, but my application is not visible in taskbar.
Form has minimize, maximize and close buttons. When I click minimize, form minimizes to a small form in the bottom left corner on the screen, but doesn't show up in the taskbar.
Is your form modal?
MyForm.Show vbModal
If so then you'll have to do something like this to make it show in the taskbar.
This question is old but I still work with VB6 on a daily basis. I found this work around to make a form shown by MyForm.Show vbModal appear on the taskbar.
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub Form_Activate()
Call ShowWindow(Me.hWnd, vbHide)
Me.Caption = Me.Caption
Call ShowWindow(Me.hWnd, vbNormalFocus)
End Sub

How do I locate a Word application window?

I have a VB.net test application that clicks a link that opens the Microsoft Word application window and displays the document. How do I locate the Word application window so that I can grab some text from it?
You can use the Word COM object to open the work document and then you manipulate it. Make sure to add a reference for Microsoft Word first.
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop.Word
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strFileName As String
Dim wordapp As New Microsoft.Office.Interop.Word.Application
Dim doc As Microsoft.Office.Interop.Word.Document
Try
doc = wordapp.Documents.Open("c:\testdoc.doc")
doc.Activate()
Catch ex As COMException
MessageBox.Show("Error accessing Word document.")
End Try
End Sub
End Class
The doc object is a handle for the instance of Word you have created and you can use all the normal options (save, print etc). You can do likewise with the wordapp. A trick is to use the macro editor in Word to record what you want to do. You can then view this in the Macro Editor. This give you a great starting point for your VB code.
Also, be sure to dispose of the Word COM objects at the end.
I've done something similar with a SourceSafe dialog, which I posted on my blog. Basically, I used either Spy++ or Winspector to find out the window class name, and make Win32 calls to do stuff with the window. I've put the source on my blog: http://harriyott.com/2006/07/sourcesafe-cant-leave-well-alone.aspx
Are you trying to activate the word app? If you want full control, you need to automate word from your vb.net app. Check here for some samples: 1, 2

Resources