Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can also see from the *.Designer.vb file that there are other properties that you may want to set. You will also have to add event handlers at runtime. You can see how to do that here.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I find the easiest way to figure this out is to place the controls in the IDE then look at the <form>.Designer.vb file that is created when you save. If you do that the sequence becomes (with a little rearranging for personal taste)

  1. Create the tab control and add it to the form
  2. Create the tab pages and add them to the tab control
  3. Create controls for the individual tab pages and add them to that page

Here is some sample code to use on a blank form

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

    'Create the tab control and add it to the main form

    Dim tbc As New System.Windows.Forms.TabControl()
    tbc.Location = New Point(10, 50)
    tbc.Name = "tbcMyTab"
    Me.Controls.Add(tbc)

    'Create three tab pages and add them to the tab control

    For i As Integer = 0 To 2
        Dim tbp As New System.Windows.Forms.TabPage()
        tbp.Text = "Page " & i
        tbc.Controls.Add(tbp)
    Next

    'Create a text control and add it to the last tab page

    Dim txt As New TextBox
    txt.Text = "default text"
    tbc.TabPages(2).Controls.Add(txt)

End Sub

Keep in mind that unless you declare tbc at the class level you will have to refer to the control in other subs/functions as

Dim tbc As TabControl = Me.Controls("tbcMyTab")
tbc.TabPages ... etc

The same thing applies to any other controls you add to the tab pages.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That tells me that _Req is of type HttpWebRequest. That does not tell me the type of WebRequest. I am assuming the error is caused by accessing WebRequest from a background thread. I am also assuming WebRequest is an instance of a control (I didn't see a declaration so I don't know) If that is the case then the following might work (and it might not). If WebRequest does not support InvokeRequired then this will not work.

Main Thread

Private Delegate Function dlgMakeWebRequest(req As String) As HttpWebRequest

Private Function MakeWebRequest(req As String)

    If WebRequest.InvokeRequired Then
        Dim dlg As New dlgMakeWebRequest(AddressOf MakeWebRequest)
        Return Me.Invoke(dlg, req)
    Else
        Return WebRequest.Create(req)
    End If

End Sub

Background thread

Public Function _ValiAcc(ByVal url As String, ByVal usrname As String, ByVal passwrd As String, ByRef result As String)
    _Req = MakeWebRequest(url & "login.php?u=" & usrname & "&p=" & MD5_encode(passwrd))
    _Resp = _Req.GetResponse
    _GStream = _Resp.GetResponseStream
    _ReadS = New StreamReader(_GStream)
    result = _ReadS.ReadToEnd()
    Return result
End Function
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You sent me Dragon.rar which does not contain the code that declares WebRequest. Unless I know what WebRequest is I can't say whether or not I have a solution.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Is WebRequest declared in the main thread?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That depends. Is it very large? I'm not really keen on wading through several thousand lines of possibly undocumented code. And is it something I can run on my computer without setting up a special environment? I would also have to be vb.net 2010. How about just posting the code for the eFunctions class to start?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I posted a reply but it disappeared. Is it possible either eFunctions._ValiAcc is being called from two different threads at the same time, or that the code in eFunctions._ValiAcc is trying to modify a foreground control? The second scenario is usually what causes the error you are seeing.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Private Sub loginWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles loginworker.DoWork
        Try
            MySub(My.Settings.adress, tbuser.Text, tbuser.Text & tbpwd.Password, eResult)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
        End Try
    End Sub
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Private Delegate Sub dlgMySub(addr as String, user as string, pass as string, eResult as String)

Private Sub MySub(addr as String, user as string, pass as string, eResult as String)

    If efunctions.InvokeRequired Then
        Dim dlg As New dlgMySub(AddressOf MySub)
        Me.Invoke(dlg, addr, user, pass, eResult)
    Else
        eFunctions._ValiAcc(addr, user, pass, eResult)
    End If

End Sub
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Let's say you want to modify the value of a label from a background thread. You can't do that directly so you create a delegate. At the class level in the maini form you do something like

Private Delegate Sub dlgUpdateStatus(text As String)

and in the main thread you have the sub

Private Sub UpdateStatus(text As String)

    'The InvokeRequired method returns True if the thread that calls
    'it is running from a different thread. In that case we create a
    'delegate to do the update of the control's text otherwise we can
    'update the text directly.                                                         
    If lblStatus.InvokeRequired Then
        Dim dlg As New dlgUpdateStatus(AddressOf UpdateStatus)
        Me.Invoke(dlg, text)
    Else
        lblStatus.Text = text
    End If

End Sub

You can call this sub from the main thread or any other thread and it will do the update properly.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You have to use a delegate. There is an example here

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You'll have to explain that a bit better. I don't understand what you are asking.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

What .net framework are you running. I think you need at least 4.0 (possibly 4.5)

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You could store each player's cards in an array and assign the ListBox DataSource as needed. Here is an example:

Public Class Form1

    Private list1() As String
    Private list2() As String

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        list1 = {"a", "b", "c", "d", "e"}
        list2 = {"f", "g", "h", "i", "j"}

    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        ListBox1.DataSource = list1
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        ListBox1.DataSource = list2
    End Sub

End Class
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I suggest you use regular expressions. I can give you an example but first I would have to know the range of values that you will be replacing. For example, will the value in quotes always be three digits? Does the string

l="600"

always appear on its own line or can it occur within a line as in

Some text l="600" some other text
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Assuming that you are replacing the text in the file with the new text, I would do the following

Dim text As New System.Text.StringBuilder

text.Append("1st line of text" & vbCrLf)
text.Append("2nd line of text" & vbCrLf)
text.Append("3rd line of text" & vbCrLf)
.
.
.    
System.IO.File.WriteAllText(filename,text.ToString())

Depending on how many lines you have, repeated concatenation as in your code can get noticibly slow. StringBuilder is much more efficient. Try the following and see for yourself.

Dim text As String = ""

For i As Integer = 1 To 1000
    text &= "this is line " & i & vbCrLf
Next

and compare it to

Dim text As New System.Text.StringBuilder

For i As Integer = 1 To 1000
    text.Append("this is line " & i & vbCrLf)
Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

How about just putting the delete code in a Try-Catch block and seeing what error occurs if the table does not exist? That will tell you what error to ignore.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You are referencing the checkboxes as generic controls and the generic control does not have a Checked property. Try referencing as Checkboxes as

For Each cbx As CheckBox In Me.Controls.OfType(Of CheckBox)()
    cbx.Checked = True
Next

As you pointed out this only looks at controls that are directly in the form. If the controls are in another containing control such as a GroupBox then this won't work. You'd have to rewrite as

For Each gbx As Groupbox In Me.Controls.OfType(Of GroupBox)()
    For Each cbx As CheckBox In gbx.Controls.OfType(Of CheckBox)()
        cbx.Checked = True
    Next
Next

That will handle all CheckBoxes in all GroupBoxes. You can just do a specific GroupBox by

For Each cbx As CheckBox In GroupBox1.Controls.OfType(Of CheckBox)()
    cbx.Checked = True
Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Try

qry2 = "SELECT * FROM [per_diem_accomodation]  " &
       " WHERE [project number]  = '" & projcode & "'" &
       "   AND [employee number] = '" & empcode  & "'" & 
       "   AND [current month]   =  " &
       "       (SELECT MAX([current month])    " &
       "          FROM [per_diem_accomodation] " &
       "         WHERE [project number]  = '" & projcode & "'" &
       "           AND [employee number] = '" & empcode  & "')"

You left out the square brackets inside the MAX statement. I find that creatinig column names with embedded blanks is usually a bad idea. I finid it easier to debug SQL statements when they are formatted as above across several lines. Ii find them even easier to debug when using parameterized queries.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I've never tried it on an Access database. I suggest you create a dummy table and try it out.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Try

IF OBJECT_ID('myTable','U') IS NOT NULL DROP TABLE myTable
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Do all of the tables have the same structure? What is that structure? Are you getting any error messages? Try changing

qry = "INSERT INTO [ptempTable] ([project number],[project name],[description]) VALUES ('" & projcode & "','" & projname ,"'" & description & "')"

to

qry = "INSERT INTO [ptempTable] ([project number],[project name]," &
      "[description]) VALUES ('" & projcode & "','" & projname & "','" & 
      description & "')"

It looks like you have a formatting error between projname and description. Are you using OleDB, or SqlDB? If you use parameterized queries you would be less likely to see these types of formatting errors. Please see here for examples of both.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You'll have to try explaining again. Your description is very confusing.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'd look for another vet. That's an absurd price.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

There are a thousand ways that an application can "not work". What happens when you run it?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That is true but the point was that if the dog's ears fold down then they are more likely to get dirty and infected. If they stand up (for whatever reason) then they will stay dry.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can try equal parts of vinegar and warm water. Use cotton balls (not Q-Tips).

@AD - Ew!

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

As you've heard several times over, take your dog to the vet. He/she can check for infection and suggest a cleaning solution which should be used on a regular basis. Dogs with floppy ears like setters, spaniels, basset hounds, etc. tend to be more susceptible to this problem because the ears stay more moist. We had to swab our Irishes regularly. Our Shepherd/Husky cross never had this problem.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Here's an example. I created a blank form, added a picturebox, then added a label at the centre of the picturebox. Note that even though the label is over the picturebox, it is actually containied in Me.Controls. In the following code, only the line that has the comment "run time" actually has to be in the code. The other three lines set properties that can be set in the designer. This code gets executed when the form loads and does not require that you click on anything.

Public Class Form1    

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Me.BackColor = Color.Azure             'design time
        PictureBox1.BackColor = Color.Coral    'design time
        Label1.BackColor = Color.Transparent   'design time
        Label1.Parent = PictureBox1            'run time

    End Sub

End Class

Your problem was that when you double clicked on the picturebox in the designer it automatically created a handler for PictureBox1_Click. That is where you added your code and that is why you had to click on the control to execute that code at run time.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

In the form load event handler just add the code to put the label in the proper container. You can set the transparent property there at run time or in the designer.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It works for me. What version of vb are you using (I am on vb 2010)? If you added the code after double clicking the picturebox then the code won't execute until you click in the picturebox at run time. Try putting it in the form load handler.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It makes a nice companion site for 99 bottles of beer on the wall

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

My e-reader (on the laptop) allows me to add "sticky" notes. Having my computer reference books in eform allows me to use Search to find things more easily. Also, if I have to help a friend I can just load up my reference books on a USB stick and tote it along, or even take along the laptop.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You should set

sngTotal = 0

just prior to

For intCounter = 0 To 2 

And you should probably change the loop to

For intCounter = 1 to 3

You should also validate the entered grade to ensure that it is a number and falls in the range 0-100. You can omit the test

If intNumScores > 0 Then 

Because you are doing

Do Until intCount > intNumScores

and because intCount starts at 1, you are guaranteed that intNumScores will never be zero.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I tested the query on a sample database and it worked just the way you want.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Try

SELECT * FROM Table
 WHERE DateDeleted < '2014-02-12'
    OR DateDeleted IS NULL
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I don't see the problem. You can have multiple timers with custom code for each.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Why not just

Public Class Form1

    Private CountDown As Integer

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        CountDown = 15
        Timer1.Interval = 1000
        Timer1.Start()

    End Sub

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick

        CountDown -= 1

        If CountDown > 0 Then
            Me.Text = CountDown
        Else
            Me.Text = "timer expired"
            'add call to custom sub here
            Timer1.Stop()
        End If

    End Sub

    Private Sub btnReset_Click(sender As System.Object, e As System.EventArgs) Handles btnReset.Click
        Me.Text = CountDown
    End Sub

End Class
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Try running it in a command prompt as Administrator.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I like to have a mix. I like the adjustable fonts of an ebook reader but I need a paperback when I want to read in the hot tub. I don't have a dedicated ebook reader like Kindle or Nook. I just use Calibre on my laptop.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Can you post the code that you are running? It would also help if you could post the value of qry after

Debug.WriteLine(qry)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You could do

Dim qry As String = "SELECT COUNT(*) AS numrec FROM Applicant" &
                    " WHERE LAST_NAME  = '" & txtappln.Text & "'" &
                    "   AND FIRST_NAME = '" & txtappfn.Text & "'" &
                    .
                    .
                    .
rs.Open(qry, con, 2, 3)

If rs("numrec").Value = 0 Then
    'the record does not exist
Else
    'the record exists
End If

This assumes you are using ADODB. To see how to do this using OleDb with parameters (which you should be doing) please see here.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I don't have that particular key so I can't run the same test, however, my example does show that the brace brackets are not the cause of the problem.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

“I always said that if I wasn’t studying psychopaths in prison, I’d do it at the stock exchange.” – Robert Hare, creator of the Hare Psychopathy Checklist

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

@oussama - How long did it take you to unravel that?

For expressions that already evaluate to Boolean there is no need to do the comparison so

If q.Created = True Then

can be written as

If q.Created Then
oussama_1 commented: got it, thanks +3
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I did this

Dim key As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{002568CE-7595-46A3-A1C1-53F41A4ADC34}"
Dim regKey As RegistryKey = Registry.LocalMachine.OpenSubKey(key, False)

If regKey Is Nothing Then
    MsgBox("Registry key does not exist!")
Else
    MsgBox("Registry key exists.")
End If

on my system (Windows 7 Pro) and it worked just fine. Note that I used False as the second parameter to avoid a System Security Exception.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

In the FormClosing you could always do

e.Cancel = True

But you should also give the user some other way to exit. For example, if the user selects Exit from a menu you could set a class flag as in

Private ReallyExit As Boolean = False

Private Sub Form1_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
    e.Cancel = ReallyExit
End Sub

Just make sure that somewhere in your code you do

ReallyExit = True
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

OK. Try

Dim name As String = "pnl" & ChrW(columnsCode) & ChrW(rowsCode)
Dim pnl As Panel = Me.Controls(name)
Me.Controls.Remove(pnl)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Your loop is creating a new Panel (pnl) then trying to remove it from the Me.Controls collection but you never added it to the Me.Controls collection to begin with. If you are trying to get a reference to a panel for deletion then you should not use the New keyword. If pnl.Name is the name of the panel you want to delete then you don't even need to create a reference. You can delete it by

For i As Integer = 1 To rows
    Dim rowsCode As String = "&H" & (i + 30).ToString()
    Dim name As String = "pnl" & ChrW(columnsCode) & ChrW(rowsCode)
    Me.Controls.Remove(name)
Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I presume no is classNo. This doesn't appear in either of the two tables so you would have to generate it in the query as in

INSERT INTO classroom
SELECT 1 AS classNO, lname, fname FROM table1 
UNION 
SELECT 1 AS classNO, lname, fname FROM table2

However, the new table will give you no way to determine who is a student and who is faculty.