Minimalist 96 Posting Pro

Why don't you just show a second one? Like:

Private Sub Form_Load()
Dim msg1, msg2 As String
msg1 = InputBox(prmpt1)
msg2 = InputBox(prmpt2)
Debug.Print (msg1 & "   " & msg2)
End Sub
Minimalist 96 Posting Pro

This question cant be understood. What do you mean a datagrid upgrades if you click on a textbox?

Minimalist 96 Posting Pro

Well if this works well done. Please mark the thread as solved. Thanks

Minimalist 96 Posting Pro

just search this site with 'connect with sql' there are plenty of posts

Minimalist 96 Posting Pro

if you got a solution please mark the thread as solved. Also, you wouldn't need my array because you are feeding the values from your database. Also check out dynamic arrays and how to resize these without loosing data.

Minimalist 96 Posting Pro

Use & instead of + and the general code snippet is:

Dim strFileName As String
strFileName = File1.Path
If Right$(strFileName, 1) <> "\" Then strFileName = strFileName & "\"
strFileName = strFileName & File1.FileName
Main.Show
Main.Image.Picture = LoadPicture(strFileName)
Minimalist 96 Posting Pro

Can you show some code so we know where it has to go - buton click, key event ?

Minimalist 96 Posting Pro

Well, you can't just copy my code into your program before thinking about or trying it on its own. If you copy the code I give you now into a small testing program as it is it will work. You need to modify to your needs so.

Private Sub Form_Load()
Dim str As String
Dim ar(5) As String
ar(0) = "apple"
ar(1) = "banana"
ar(2) = "plum"
ar(3) = "apple"
ar(4) = "plum"

Debug.Print (Combo1.ListCount)
For i = 0 To 4
    str = ar(i)
    For j = 0 To Combo1.ListCount - 1
        If str = CStr(Combo1.List(j)) Then
        MsgBox ("Double Entries not allowed")
        Exit For
        End If
    Next
    If str <> CStr(Combo1.List(j)) Then
        Combo1.AddItem str
    End If
Next
End Sub
Minimalist 96 Posting Pro

1) I would check that there is nothing in any of the 3 keypress events
2) I would move the calculations of the row somewher else
3) If nothing changes I would create a new datagrid on the form, input some values, use the double click and if this works O.K I would check if some of the properties are different to the datagrid you use.

Minimalist 96 Posting Pro

If you don't want anything happen on the key enter just don't use it.

 Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress
        Dim NotAllowed As String = "~`@%^&+={[}]()!:,;'><?/|\-.#+()_$*"
        If e.KeyChar <> ControlChars.Back = True Then
            If NotAllowed.IndexOf(e.KeyChar) = -1 = False Then
                e.Handled = True
            End If
        End If
    End Sub
Minimalist 96 Posting Pro

O.K I just go back to the original post as this seemed to work and change it to:

ACRS.Open "SELECT * FROM Salary1", CN, adOpenStatic, adLockOptimistic
dim j as integer 'need to count items in combo
Sfm = ACRS!Month
Do Until ACRS.EOF
  For j = 0 To CmbSfm.ListCount - 1 'each item check against all items in the combo
   If Sfm = CStr(CmbSfm.List(j)) Then
      MsgBox ("Double Entries not allowed")
     else
     CmbSfm.AddItem ACRS!Month
    End If
ACRS.MoveNext
Loop
Minimalist 96 Posting Pro

O.K I can't replicdate this behaviour. What you can do is insert this code and double click in different rows, different cells and see if the values in the cells are return to the debug window. If yes, there is a bug in your code or you need to use another event to calculate your rows. Using debugging your code and go with the mouse over yourvariables will also display the values.

Private Sub DataGridView1_CellMouseDoubleClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseDoubleClick
        Debug.Print(DataGridView1.CurrentCell.Value.ToString)
    End Sub
Minimalist 96 Posting Pro

So what happen if you enter a value and move with the arrow keys?

Minimalist 96 Posting Pro

Check the keypress event of the datagrid.

Minimalist 96 Posting Pro
Minimalist 96 Posting Pro

The error means that you haven't instanciated your workbook. The folowing is I think the way to do it:

'Instantiate a Workbook object.
'Load a template file.
Dim workbook As Workbook = New Workbook("d:\test\MyBook.xls")

'Get the first worksheet in the book.
Dim sheet As Worksheet = workbook.Worksheets(0)

'Insert 10 rows at row index 2 (insertion starts at 3rd row)
sheet.Cells.InsertRows(2, 10)

'Delete 5 rows now. (8th row - 12th row)
sheet.Cells.DeleteRows(7, 5)

'Save the excel file.
workbook.Save("d:\test\out_MyBook.xls")
Minimalist 96 Posting Pro

Well I googled it again and went a bit further.The conclusion is that there are many reasons that error can be thrown. It would be helpful to see the original code that worked and the code that you edited and throws the error.

Minimalist 96 Posting Pro

Please mark it solved. Thanks

Minimalist 96 Posting Pro

Well, you need to adopt the code to what you need. Ishowed you haw to prevent double entries. Since I used only one word, the first time it is added to the combo, after I exit the sub in line 9. You need to put your code there to handle it - means you can't exit the sub.

Minimalist 96 Posting Pro

Well you asked the question yourself "What did happen?". Something must have changed. Some one fiddling with the code?, data has changed?, the feature has not been used before? If you google arror 91 and vb6 you will find many reasons - the main one as your error described.

Minimalist 96 Posting Pro

Well, if they wouldn't put in new features why would they upgrade from vers.1 to vers. 4.5. You find everything here:
http://msdn.microsoft.com/en-us/library/ms171868(v=vs.110).aspx

Minimalist 96 Posting Pro

You have set your object in a subso the scope only works in the sub. Do the same in the othe sub or declare the object on top of yxour code.

Minimalist 96 Posting Pro

There must be some in your program that overrides your setting. You can try this at the form load event:

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
    End Sub
Minimalist 96 Posting Pro

The higher the version number the more features are built into the framework. The problem is that not every one is upgrading to the highest version of the framework. If you compile to lower version you might lose features you are using in your program. Better is to check before install which version is installed and asked user to install latest version as it is free asnyway.

Minimalist 96 Posting Pro

o.K. thought it would work but its vb.net. The following code works, I just tried it. You need to adapt so.

Private Sub Form_Load()
Dim str As String
For i = 0 To 2
str = "Hello"
Debug.Print (Combo1.ListCount)
For j = 0 To Combo1.ListCount - 1
If str = CStr(Combo1.List(j)) Then
MsgBox ("Double Entries not allowed")
Exit Sub
End If
Next
Combo1.AddItem str
Next
End Sub
Minimalist 96 Posting Pro

Just prevent adding the string to the combobox by checking if it is already in the string collection of the combobox like (don't know if it works):

 If ComboBox1.Items.IndexOf(str) = -1 Then
                ComboBox1.Items.Add(str)
            End If
Minimalist 96 Posting Pro
Public Class Form1
    Dim counter As Integer = 1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        test() 'this is calling the sub named test
    End Sub
    Private Sub test()
        Dim myMessage As String
        Dim Prompt As String = "Input Password"
        Dim title As String = "Inputbox Test"
        Dim defaultText As String = ""
        Dim userpassw As String = "Me"
        myMessage = InputBox(Prompt, title, defaultText)
        If myMessage = "Me" Then
            MessageBox.Show("Password Correct")
        Else
            MessageBox.Show("Wrong Password or Cancel pressed")
            counter = counter + 1
            If counter > 2 Then
                MsgBox("Entry Failed, Good bye")
                End
            End If
            test()
        End If

    End Sub

End Class

You realy should google for the topics you are working with. The above code will do what you are supposed to be doing, try to understand it. Don't forget to close the thread and give credit.

Minimalist 96 Posting Pro

@Jim
shouldn't that be Dim checks As Double = CDbl(TextBox1.Text) also OP has 2 threads now for the same topic

Minimalist 96 Posting Pro

In line 12 you are assigning checks to a textbox. Maybe you wanted checks to be what is in the textbox
checks= CDbl(TextBox1.Text)

Minimalist 96 Posting Pro

You are declaring Fee as double on th top and than returning an Integer in line 24
In line 12 you are assigning a double to a textbox ?
textbox1.text= Cstr(checks)?

Minimalist 96 Posting Pro

You can't use checks to count the clicks. This could be anything. You need to setup a proper counter tha tincreases each time th bvutton is clicked. Use the button.click eventhandler for this.

Minimalist 96 Posting Pro

You are not showing enough code. Where do you count the clicks and under which condition?

Minimalist 96 Posting Pro

ElseIf checks < 39 Then
This doesn't give you the range 20 -38 but th range 0-38

Minimalist 96 Posting Pro

From the line 3 I can see that you didn't read up on inputbox - google it. Here is a link:
http://msdn.microsoft.com/en-us/library/6z0ak68w(v=vs.90).aspx
Do you know about functions, subroutines and about the scopes of variables -I am asking because I don't understand what you want to achieve in line 1.

Minimalist 96 Posting Pro

I don't understand. You mean edit the code or put data into a form and than try to save. Also use debug and show the code where the error is raised.

Minimalist 96 Posting Pro

Go to the menu bar -> File-> make project.exe and check out the options

Minimalist 96 Posting Pro
'You better read up on the inputbox methods.
'Declare all the values and variables
Dim message as string="Enter the password"
Dim title as string = "InputBox Demo"
Dim defaultValue As String = "Me"
' this code set up your inputbox
' You are supposed to use a loop
'The loop is meant to count to 3 on three different entries
'You need to declare an Integer outside the loop and increase it inside the loop
Dim intCount as Integer=0

See if you can work it out from here

Minimalist 96 Posting Pro

They don't have to be in the same position. Look at this example:
http://msdn.microsoft.com/de-de/library/bb460136(v=vs.90).aspx

Minimalist 96 Posting Pro

Intersection returns only the elements that are contained in both sets. It doesn' rtell you how many or at which positions they are.

Minimalist 96 Posting Pro

O.K. put a button on your form and paste the code into it.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim word1 As String = TextBox1.Text
        Dim i As Integer
        For i = 0 To word1.Length - 1
            MsgBox(word1.Chars(i))
        Next
    End Sub

This runs through the word in textbox1 and displays every charcter in a msgbox until it wnt through the whole word. The rest you should be able to do yourself

Minimalist 96 Posting Pro
Minimalist 96 Posting Pro

Sorry but you completely lost me with the my.settings stuff. I don't understand what you want to achieve with this?
This will not work:

 MySource = My.Settings.ListBoxCollection1
            MySource = My.Settings.ListBoxCollection2

If assign values to a variable the variable will only hold the last values assigned to it. x=5 and x=7 means that x=7 and not 5 and 7
Since I live in another part of the world there will be delays.

Minimalist 96 Posting Pro

No, you don't need too. The code will work with any collection.

Minimalist 96 Posting Pro

In line 2 you have to clear the listbox
ListBox1.Items.Clear()

Minimalist 96 Posting Pro
Private Sub TextBox1_KeyUp(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyUp
        Dim strOr As String, strReturn As String, strL As String, valueL As String

        strOr = Trim(TextBox1.Text)
        strL = UCase(Trim(TextBox1.Text)) 'hold input in lower case
        TextBox2.Text = ""
        ListBox1.ClearSelected()
        For Each value As String In MySource 'returns the origanal string from list
            valueL = UCase(Trim(value)) 'hold string from list in lower case
            If InStr(valueL, strL) > 0 And strOr <> "" Then 'now compare only lower cases
                strReturn = value ' now we found a match so we use the original string again
                TextBox2.Text = TextBox2.Text & strReturn & vbNewLine
                ListBox1.Items.Add(strReturn)
                ' put code for highlighting here
                Dim ind As Integer = ListBox1.FindString(strReturn)
                If ind <> -1 Then
                    ListBox1.SetSelected(ind, True)
                End If
            End If
        Next
        If TextBox1.Text <> "" Then
            Button1.PerformClick()
        End If
    End Sub

I could' exactly remember what I changed - too busy. Ok I copy the code for the TextBox1_KeyUp event. Try this:

Minimalist 96 Posting Pro

Replace: Button1.PerformClick() with

If TextBox1.Text <> "" Then
            Button1.PerformClick()
        End If

Delete textbox2 and the referring code

Minimalist 96 Posting Pro

I you copied my code and have a button1 to clear not selected items you can just insert the following line at line number 26 in the code above
Button1.PerformClick()
this will call the eventhandler of button1.

Minimalist 96 Posting Pro

Did you get the code to work? And to your question: no a listbox ist not meant to this. Either use a listview control or use multiple listboxes synchronised - which is not easy. If you got the former part working as you wanted please close this thread as solved and mybe start another one.

Minimalist 96 Posting Pro

It only takes a few lines and works a charm. Icommented the code a bit. I removed the button to populate the list and do it at form load. The codeposted goes into the TextBox1_KeyUp event.

 Private Sub TextBox1_KeyUp(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyUp
        Dim strOr As String, strReturn As String, strL As String, valueL As String
        strOr = Trim(TextBox1.Text)
        strL = UCase(Trim(TextBox1.Text)) 'hold input in lower case
        TextBox2.Text = ""
        ListBox1.ClearSelected()
        For Each value As String In MySource 'returns the origanal string from list
            valueL = UCase(Trim(value)) 'hold string from list in lower case
            If InStr(valueL, strL) > 0 And strOr <> "" Then 'now compare only lower cases
                strReturn = value ' now we found a match so we use the original string again
                TextBox2.Text = TextBox2.Text & strReturn & vbNewLine
                ' put code for highlighting here
                Dim ind As Integer = ListBox1.FindString(strReturn)
                If ind <> -1 Then
                    ListBox1.SetSelected(ind, True)
                End If
            End If

        Next
        If TextBox1.Text = "" Then
            ListBox1.Items.Clear()
            Dim str As String
            For Each str In MySource
                ListBox1.Items.Add(str)
            Next
        End If

Good luck and if that is all please marke the thread as solved

Minimalist 96 Posting Pro

The problem is that you can get a combination of lower and upper case letters in the owrd list and mybe typos. So what you can try is to declare another string variable to change all inpu to lower case, do the same for the string that is returned from your list, compare these and if a match is found highlight the original word in your list.