The code from the post above will test the value in the textbox before entering it into the listbox.
This should accomplish what you are wanting, as for the guessing part, you will have to drop your code in.
I hope this helps. :)
The code from the post above will test the value in the textbox before entering it into the listbox.
This should accomplish what you are wanting, as for the guessing part, you will have to drop your code in.
I hope this helps. :)
Ah, you are storing the values IN the listbox. So the code I posted will be checked every button click, therefore, it will throw a message box(testing values that are already in the listbox)
Is it possible to use a textbox to type, and a listbox to store?
If this is possible, you can just check to see if the item is in the listbox:
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
If IsDuplicate(TextBox1.Text) = False Then
ListBox1.Items.Add(TextBox1.Text)
Else
MsgBox("You have already guessed this letter.")
End If
End Sub
Private Function IsDuplicate(ByVal StringIn As String) As Boolean
'Cycle and Check
For i = 0 To ListBox1.Items.Count - 1
If ListBox1.Items(i).ToString.ToLower = StringIn.ToLower Then
Return True
End If
Next
'Return false (None were found)
Return False
End Function
My question would then be, how are they entering/chosing from a listbox.
Are you allowing only 1 char, or an entire string?
And why a listbox and not a textbox?
You could try to add it to an array then search the array for it:
Dim lstString As New List(Of String)
'Assuming they have to press a button to submit their letter
Private Sub Button_Click(sender as object, e as eventargs)Handles Button1.Click
If lstString.BinarySearch(ListBox1.Text.ToLower) <> -1 Then
MsgBox("You can only enter a letter once!")
Else
lstString.Add(ListBox1.Text.ToLower)
End If
End Sub
You could do that, or create flow layout panel containing the buttons for A-Z and disable the button on click.
There could be a number of problems wrong, but first I would start small.
The easiest test to do would be to plug the laptop into a desktop monitor using the VGA port.
If this works, it could mean any of these:
Bad LCD (Replace LCD)
Bad Inverter (Replace Inverter)
Bad Inverter Cable (Replace Cable)
Bad Onboard GPU (Replace Motherboard)
If this doesn't work, it still wont rule out a bad GPU.
It could also mean that you have bad memory, which can be accessed through a small port on the bottom of the laptop. (Typically one screw that can be removed on a 3"x3" panel)
You can test the memory by removing the sticks one and a time, and booting the pc (Swapping the first with the last...ect...)
If this does not work, you will have to take the laptop for a service shop ( or some one who knows a great deal about hardware) to get them to look at it for you.
Try something like an IIF statement:
Col1 = IIF(IsDBNull(ds.Tables("myTable").Rows(intCurRow)("Caste")),"MY DEFAULT VALUE HERE",ds.Tables("myTable").Rows(intCurRow)("Caste"))
Im sorry, but we can't give you ideas.
That's not how the creative process works. You will have to find the ideas on your own, but if you need help with your code..We can help.
We are offer help, not homework solutions.
Some connection types include:
1)OleDB
2)SQLClient
3)ADO
If you are popoulating the listbox with a dataset, you just need to refresh the data.
What connection type are you using?
If you take a screen shot of the the exception that is thrown, along with the message - We can trouble shoot it for you (hopefully)
Try placing MsgBox(ex.ToString) in the Try/Catch block.
Try
'Your Code Here
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Are you retreiving a large amount of records?
Access databases can only be open by one user at a time.
It would be wise to open a connection , read all data, then close the connection.
If you are using a dataset to fill your listview, and the records are added by dataset row, you can do this.
MyDataSet.Tables("myTable").Rows(indexFromListView).Delete()
MyDataAdapter.Update(MyDataSet.Tables("myTable"))
Also, you want to use the DTP's .Value attribute, not .Text
Here is an article on CodeProject that contains all the source code to do exactly what you are wanting.
For Memory:
Pull one module out at a time, swapping them till you find the bad module (if any)
CMOS:
No, resetting the CMOS will not whipe a hard drive, but can/will reset the boot settings.
You are referencing the index of the listview only.
This will ONLY work on the very first delete (Assuming you have an identity column that matches the exact indexes of the listview(Extremely unlikely))
You will need to reference a unique value from the list view item, otherwise, you can only remove it form the listview - not the database.
For example:
(HideThisColumn|Col1|Col2|Col3)
( 3|Name|Date|Info)
( 5|Name|Date|Info)
( 6|Name|Date|Info)
( 9|Name|Date|Info)
If you stored the database indentity column in the first column of the list view, but hid the column, the user will only see col1, col2 and col3.
So when the user clicks the column " 5|Name|Date|Info " You know that that corresponds to the database entry with an identity of 5.
By using the index of the item ( What you are doing now ) you will try to execute a delete statement on the index of 1 (2nd item in the list) which will produce undesired outcomes.
What I like to do when using listviews, is to load the table's identity column into the first column of the listview. (Then make the column width 0 to hide it from the user)
Then to reference it, I use:
Dim myUnique As String 'Your data type here
If IsNothing(ListView1.SelectedItems) = False Then
For Each Itm as ListViewItem in ListView1.SelectedItems
myUnique = Itm.Text
Next
Else
MsgBox("Please select an item first!")
End If
You have just referenced the identity that is stored in the first (hidden or not) column of the row.
You can now use this to manipulate data/the list view.
Try This:
Dim MyTable As String
MyTable = "Table1"
For i = 0 To ds.Tables(MyTable).Rows.Count - 1
'Do Work
Next
Try
If TextBox1.Text = "A" Or TextBox1.Text = "B" Or TextBox1.Text = "C" Then
'Do Work
End If
If you are using SQL as a backend, you try the command:
Dim cmd As New Oledb.OledbCommand("INSERT INTO table2(YesCount) SELECT COUNT(*) FROM table1 WHERE table1.Status='Yes'",YourConnection)
Give this a try
Could be throwing a null reference exception as well.
Try replacing:
TextBox1.Text = myDataSet.Tables(0).Rows(SelectedIndex).Item("Equipment_ID").ToString
With:
TextBox1.Text = IIF(IsDBNull(myDataSet.Tables(0).Rows(SelectedIndex)("Equipment_ID")),"",myDataSet.Tables(0).Rows(SelectedIndex)("Equipment_ID"))
What problems are you getting with this code?
If you are not hearing the POST (Power On Self Test) Beep, or you are hearing multiple beeps (error) then I would first look at memory (most likely the culprit).
Are you running Crossfire/SLI? (Dual Video Cards Crossfire(ATi) SLI(Nvidia))
If you are making an app for "live" data manipulation you need to research what methods you want to use:
DataGrid
ListViews
Reports
Ect...
You will need to design your tables on an atomic level(3NF) and design your GUI for the end user (not your own preference).
You will need to look at deployment methods as well.
Some of these include:
ClickOnce
InstallShield
InnoSetup
Hope this gets you started!
Also, if you are simply wanting to copy one file from one location to another, you can use this call:
Dim outFileName As String = "myTXT.txt"
Dim input As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\myTXT.txt"
Dim output As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\TEST\" & outFileName
If IO.File.Exists(input) Then
If IO.Directory.Exists(output.TrimEnd.TrimEnd(outFileName.ToCharArray)) = False Then
If MsgBox("Directory does not exist:" & vbCrLf & output.TrimEnd(outFileName.ToCharArray) & vbCrLf & "Do you want to create it?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
IO.Directory.CreateDirectory(output.TrimEnd(outFileName.ToCharArray))
IO.File.Copy(input, output)
End If
Else
IO.File.Copy(input, output)
End If
Else
MsgBox("Could not find file specified:" & vbCrLf & input & vbCrLf & "Process aborted!")
Exit Sub
End If
This will make an exact copy.
When Using Click Once:
If you set the application to automaticly update in the publish settings, the next time the user starts the application - it will simply auto update for them.
When using S&D packages:
You must create a setup.exe for the application for every release
Ah, I understand now.
I think what threw me for a loop was the fact that they returned the retval (which is still an integer)
Thanks for the help!
Hello my fellow Daniwebers!
I am having some problems wrapping my head around the task sorting a List(Of CustomType)
I have a list containing a custom class.
The class contains Two DateTime objects, Start and End.
I am trying to sort the list descending so that the shortest timespan will be on the bottom of the list.
I am unsure how to write the function that returns the value to sort.
I have read Microsoft's documentation here and, as all ways, I am more confused after reading it than I was before I began.
This is what I have deducted from the article:
lstType.Sort(Address SortMyList)
Private Function SortMyList(ByVal x As Type, Byval y As Type) As Type
Try
Dim tsX As TimeSpan = x.dEnd.Subtract(x.dStart)
Dim tsY As TimeSpan = y.dEnd.Subtract(y.dStart)
If tsX > tsY Then
Return x
Else
Return y
End If
Catch ex As Exception
MsgBox("Exception from:" & ex.Source & vbcrlf & ex.Message & vbcrlf & ex.StackTrace.ToString)
'Used just to break execution
Throw New NullReferenceException("")
End Try
End Function
Would this logic be correct?
Do you have technical knowledge on how to disassemble and repair your laptop?
Or, do you know some one who does?
To replace the inverter, it requires complete disassembly. (Including the LCD enclosure.)
My advice would be to dissassemble it, check the cable, then make your purchase. This will negate the uneccessary spending of money.
The cables are fairly cheap, but the inverters can be quite expensive.
I am not aware of a way to set the location of a message box, but you can create a custom dialog box to fit your needs.
I have a custom dialog written in WinForms that has a multiline textbox for the data. (Acts just like a JIT messagebox)
Would you like me to post it?
EDIT
Took a while for the site to refresh for me, didn't know it was answered. I'm sorry for the thread revive.
You can prepare for Microsoft's new "Enlightenment" and learn HTML5/Javascript
If the vga displays an image - It's most likely the inverter/cable.
If not, it's most likely the on-board gpu/motherboard (Something more serious)
The problem is that you are setting it to just the file name.
You have to give a full path (or relative if it remains constant) to the file location and it's name.
But as yvrej17 has stated:
Click your form and set your background image in properties. Simple as that, no need for codes :)
You can do this by clicking the form in designer view, and locating the BackgroundImage property in the properties pane (defaults to the bottom right of screen) and navigating to the picture.
If you still wish to add it programmaticly you can do so this way:
'Located in the same directory as the solution.
Me.BackgroundImage = Image.FromFile(".\MyImage.jpg")
'Located in the Desktop Directory
Me.BackgroundImage = Image.FromFile("C:\users\myUser\Desktop\MyImage.jpg")
'If stored in directories above current directory.
Me.BackgroundImage = Image.FromFile("..\..\MyImage.jpg")
' Two directories ^
An IP with the prefix octet of 192 is always a private IP Address.
You will have to assign the server a static (unchanging) ip for outside users to be able to connect.
Here is some material for you to read/research.
From my experience with dells, it is most likely the inverter/inverter cable.
The cables range from $10-$30 and the Inverter is around $100 (For the model I was repairing.)
You can confirm this by plugging the laptop into a monitor using the vga port.
Is the report an embedded resource?
You will need a for statment to cycle through the listview.
(This only works where a unique value is present for each entry.) (Like an ID Column)
'This assumes that the CODE field is unique to each database entry!!
For Each li as ListViewItem In ListView1.Items
With OleDa
.DeleteCommand = "DELETE FROM table WHERE CODE=@CODE"
.DeleteCommand.Parameters.Add("@CODE",OleDb.OleDbType.VarWChar, 50, "CODE").Value = li.SubItems(1))
.DeleteCommand.ExecuteNonQuery()
End With
Next
First, please start a new thread for help. Don't hijack dead threads.
Second,I had found an open source library from here.
I have modified it to allow the user to save last scanner/settings/savelocation.
Is this exception thrown from a client or the dev machine?
If this is from the client, you need to install Crystal Reports.
A label does not have a MaxLength Property, but it would probably be safe assumtion that it's a 32bit integer number.
So a label would have 2^32 maximum characters. (4294967296 possible characters)
EDIT
Here is a link that leads to an article with a custom marquee control.
We are not here for home work help.
If you have some code of your own that you are needing help with- post it.
Other than that, we are NOT going to do your homework for you.
How are you going to learn when someone does it for you?
You can try py2exe and call the exe from the vb.net application.
Example:
Process.Start("pathToMy.exe")
You can try something like this:
For i = 0 To ComboBox1.Items.Count - 1
e.Graphics.DrawString(ComboBox1.Items(i), PrintFont, Brushes.Black, horizontalPrintPosition, verticalPrintPosition)
'Leave some space for the next item.
verticalPrintPosition += 5
Next
Try handling it with an inline if statment:
If txtUsername.Text = IIF(IsDBNull(ds.Tables("AddressBook").Rows(inc).Item(1)),"",ds.Tables("AddressBook").Rows(inc).Item(1)) Then
'Do Work
End IF
It is possible that you are returning a null entry from the database, thus throwing a NRE.
By using this inline if, you return "" for null (not throwing a NRE) and can then debug it with:
MsgBox(IIF(IsDBNull(ds.Tables("AddressBook").Rows(inc).Item(1)),"",ds.Tables("AddressBook").Rows(inc).Item(1)))
Nice code snippet! Thanks, George!