Menu Strip Control "Window" - vb.net

I am working on a project and am just stymied by this. It should be really straight forward. I have included the code so you can see the other Menu Strip Items.
The user has the ability to open as many "Child" forms into the mdiParent form. I would like the "Window" function on the menu strip to populate with the Bank Name found on the Child form so if a user had 10 bank forms open, they could find a specific form by clicking Window and seeing the bank name (the name of the text field which I would like to pull is Bank.lblbank.text) This functionality was found in the 2007 and older versions of many of the Microsoft Suite products.
If I hadn't seen my professor do this in class, I would think it was a bit of proprietary Microsoft Office coding that us mere mortals cannot access. Unfortunately, he whipped it out and I didn't get it captured.
Obviously, I am not asking the right questions on the search engines because I cannot find a clear answer. Does anyone have any advice? This functionality isn't necessary but a little something I want to add. I've worked on this way too long and just want a little bit of success.
Let me know if a zip copy of the project or screen prints would be helpful. I'm happy to send them your way.
Appreciate everyone looking at this post and their feedback. Thank you for your time!
Lauren
Public Class Loan_Evaluator
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub NewLoanToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles NewLoanToolStripMenuItem.Click
Dim NewBank As New Bank
NewBank.MdiParent = Me
NewBank.Show()
End Sub
Private Sub VerticalToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles VerticalToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.TileVertical)
End Sub
Private Sub CascadeToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CascadeToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.Cascade)
End Sub
Private Sub HorizontalToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles HorizontalToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.TileHorizontal)
End Sub
Private Sub WindowToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles WindowToolStripMenuItem.Click
End Sub
End Class

Select the main MenuStrip control, not the ToolStripMenuItem. So you'd click on MenuStrip1, not WindowToolStripMenuItem, for example. Now change the MdiWindowListItem() property to "Window" (or whatever menu item you want to be populated with open MdiChildren). Done.

Related

How can I let a code run permanent in the background, which waits for an input ? (Visual Basic)

I want to program a round based rpg like game in visual basic.
For that I want to make it possible, to show a picture of the current selected unit in the right bottom corner and add some information about the heal points and some other stats.
So I want to make a program part, which permanently asks, which of the units is selected and based on that let a other program part running, which changes the picture and the information about hp and this stuff, matching to the current unit.
But I am not able to run a program which runs in the background and doesn't freezes the main program while running (may I need a background worker ?)
Also I am not very sure, what for a program type I need to used for this (like a sub or something).
I don't know other types than sub's in vb, but I could derive it from my knowledge of java programming (functions and objects).
I know this is a bit much to ask, but I need to know, which program type I need to use and how I can let it run permanent in the background + how to transfer some information between these parts.
Would be nice, if someone could help me and explain a bit instead of just saying something like: you need a background worker use this link xy.
I tried to use a variable, which becomes a different number, when a other unit is clicked, unfortunately you cant see much of my code right now, since for this form, I didn't created much more than the graphical interface.
Public Class FormBattlescreen
Dim marked As Integer = 0
Private Sub Formsounds_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
FormMainCampagne.Close()
End Sub
Private Sub OwnSoldier1_Click(sender As Object, e As EventArgs) Handles OwnSoldier1.Click
marked = 1
End Sub
Private Sub OwnSoldier2_Click(sender As Object, e As EventArgs) Handles OwnSoldier2.Click
marked = 2
End Sub
Private Sub OwnSoldier3_Click(sender As Object, e As EventArgs) Handles OwnSoldier3.Click
marked = 3
End Sub
Private Sub EnemyOfficer1_Click(sender As Object, e As EventArgs) Handles EnemyOfficer1.Click
marked = 4
End Sub
Private Sub RunGame()
Select Case marked
Case 0 'nothing is selected//at the beginning
Case 1
PictureBoxStats.Image = My.Resources.Soldier2
Case 2
Case 3
Case 4
End Select
End Sub
End Class
Thank you, I appreciate your help.

Visual Basic GUI Input Validation

I took an entry level computer programming class this past term and I'm having problems with my final project. I have to design a program in visual basic GUI that asks the player to accurately guess a number between 1-100 within a limited number of guesses.
My first form asks the user to set the number of guesses allowed. It has one textbox and an "enter" button, among other buttons that I've gotten to work.
I'm trying to get code to work that will validate the input on the guesses allowed. Specifically, I want a message box to pop up if the player enters letters or special characters instead of numbers, or enters a number less than zero, or greater than twenty. Here's what I have:
Public Class Noofguesses
Shared maxguesscnt As Integer
Private Sub Numberofguesses_TextChanged(sender As Object, e As EventArgs) Handles Numberofguesses.TextChanged
End Sub
Private Sub Quit_Click(sender As Object, e As EventArgs) Handles Quit.Click
End
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Form3.Show()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Val(Numberofguesses) > 20 Then MsgBox("Number of Guesses Cannot Exceed 20")
If Val(Numberofguesses) < 0 Then MsgBox("Number of Guesses Must Be Greater Than 0")
If Not IsNumeric(Numberofguesses) Then MsgBox("Entry Cannot be Letters or Characters")
Me.Close()
Form2.Show()
End Sub
End Class
What am I doing wrong? Please let me know.
Thanks
I would generally suggest using a NumericUpDown rather than a TextBox, in which case no validation is required. As this is an assignment though, I'm guessing that validating a TextBox is a requirement. In that case, you should use Integer.TryParse to validate a String, i.e. the Text of the TextBox and convert it if it is valid. You can then test the converted value to make sure that it isn't less than zero, etc. I'm not going to write the code for you, given that this is homework, but that should be enough for you to do it yourself or, if you feel you must, find examples online.

When to create a procedure(sub, function)

I'm currently creating my application and I'd like to write an understandable code.
I'd like to know when to create a procedure. If it affects the performance of my application if I created much.
Here is my sample:
Sample Code:
With Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Greetings()
End Sub
Private sub Greetings()
MessageBox.Show("Hello!")
MessageBox.Show("To")
MessageBox.Show("My")
MessageBox.Show("World")
End
In the example above, assume that this sub will only be called 1 - 2 times in the whole application. I like to easily understand my code.
Versus
Without Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MessageBox.Show("Hello!")
MessageBox.Show("To")
MessageBox.Show("My")
MessageBox.Show("World")
End Sub
In the example above, this piece of code too my time to understand.
In general, you should create subroutines when the logic is going to be used multiple times, especially if it's being used in multiple places.
If you ever have to change code, you want to only change it ONCE.
Performance with running basic code or calling functions is a non-issue. Do not even consider it.

How to update value in combo box using combo box text?

I have a very simple question that i can't seem to find the answer, i have looked up and down in google, msdn with no luck...
it's really simple yet i can't seem to wrap my mind around it.
here goes:
If i'm using simple Drop down style combo box(the one that looks like a listbox with textbox attached on top of the cbobx control) when i want to update one of the value in it, once i start typing in the textbox the selection inside the combo box is gone. Thus i can't update the value inside the combo box.
i know i can use a regular text box to do this, but i'd really like to make this work or i would really loose sleep over this.
Thanks in advance for all your help.
Ray
It doesnt seem very intuative editing the selection in a combobox, but the following should do the trick:
Private cbindex As Integer
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
cbindex = ComboBox1.SelectedIndex
End Sub
Private Sub ComboBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.LostFocus
ComboBox1.Items(cbindex) = ComboBox1.Text
End Sub

Dynamic dropdown based on Radio selection

Good morning all! Myself and a co-worker are tasked with a system-wide scripting solution but neither of us are .NET programmers so we need your help.
We have a GUI that displays a radio selection box (3 options) that are the three sites where our hospitals are. We need to dropdown located on the form to fill with only the locations based on the selected radio option.
my gui http://web6.twitpic.com/img/40330741-85d91a5637f2445b322e62df17cf3351.4aef01c5-full.jpg
Here is the code behind we have so far (sorry, VB)
Public Class frmCEHLI
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'CELocDataSet.dbo_Locations' table. You can move, or remove it, as needed.
Me.Dbo_LocationsTableAdapter.Fill(Me.CELocDataSet.dbo_Locations)
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
MsgBox("Submit button has been pressed")
End Sub
End Class
For the record the Location dropdown is currently databound but its a static SELECT statement which brings us all the locations but we'd prefer it to be cleaner if it only returned the locations based on Site. We are using Visual Basic 2008 Express Edition for development. Any help/code is appreciated, thanks!
Sorry not to respond back sooner, busy, and wanted to dig up a sample that did just what you were needing.
Create two comboboxes on your form. You can bind either fixed values, or from a table on the first combo. Then, from the property/events sheet, first set the "AutoPostBack" to TRUE, then on the events, click for the "SelectedIndexChanged" event to bring up some code.
The "Sender" object parameter will be the combobox itself, so you'll be able to analyse the property settings via debugging to find what key/value was chosen.
Then, run whatever query from your data querying control, business object, or whatever that gets your results, such as to a DataSet or DataTable.
Finally, set the datasource of your second combo to the above result query, set dataTextField and DataValueField and issue DataBind() to the combo.
That should get exactly what you need.
Then, when someone makes a selection from the second combo, you can have code within ITS "SelectedIndexChanged" event (also based on its AutoPostBack or actual submit button on the form).
Hope this helps.
I would create two combobox controls... One for the "where", then, on the InteractiveChange event by the user to post-back to the page using that answer for the second combobox of locations based on the "where" value of the first combo.