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

Please post the entire query.

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

Try

Table1DataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex + 1).Value = Math.Round(Val(Table1DataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) * x, 6)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Unless x is a function, it is being interpreted as an array and you cannot use an array in an arithmetic operation unless you index to a specific element.

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

Try this version

UPDATE tb2
   SET tb2.data = tb1.data
  FROM tb1 INNER JOIN tb2 ON tb1.id = tb2.id AND tb2.data IS NULL
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can try

UPDATE tb2
   SET tb2.data = tb1.data
  FROM tb1,tb2 WHERE tb1.id = tb2.id AND tb2.data IS NULL

This will update only records for which data is NULL.

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

Just ignore his posts.

It's like driving by a car accident and trying not to look. You know it will be bad, but you really want to see how bad. Or like listening to Trump to see if he could possibly top the last stupid comment.

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

I like the bang feature.

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

Only if you are logged in to Google. If you don't log in then they can't associate your search terms with a particular user.

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

I suppose I should have said all but one ;-P. Because I don't browse the C/C++ threads I can honestly say I've never seen your code (although I am sure it is exceptional - grovel, grovel). I should add that my experience is only with engineers who are self-taught programmers and all of them graduated before computer engineering was a thing. Oh the horror stories I could tell. I am pretty sure I shared the worst example of coding (FORTRAN) I ever saw in another thread somewhere. IIt was written by an engineer at Westinghouse who wrote code for a living.

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

Almost as annoying are users who ask questions that are easily answered via search.

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

There's no way of telling without seeing the query string. Replace

Dim CMD As New OleDb.OleDbCommand(simpan, CONN)

with

Debug.WriteLine(simpan)
Dim CMD As New OleDb.OleDbCommand(simpan, CONN)

and post the output here. Unless the strings you are concatenating contain "?", none of the parameters will be added. You may want to look at this to see how parameters work.

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

My choice would be to create a new table with an actual Date field and doing a copy/convert, then manually checking the fields to make sure the dates were properly converted. That's the problem with storing a date as a string. You never know if "02-03-2012" is going to convert as Feb 3, 2012 or Mar 2, 2012. By writing the code to manually convert each record you can force the correct interpretation.

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

Why not just

SELECT * FROM Consultation
 WHERE Con_Consult_Date BETWEEN '01-01-2013' AND '31-12-2013'
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you asked me to guess your profession I would have to say engineer. I never knew one who didn't write code like that.

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

I worked with a few programming jokes, but to be fair, they probably thought the same of me.

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

Don't get me wrong. I wasn't defending Microsoft. I was just pointing out some interesting numbers. When I have to get somewhere in a hurry I am much less concerned with the colour of the car than I am with its reliability and usability.

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

I can't run this locally because you supplied only the code that runs the form. I am not going to create all the controls manually and guess as to their placement or grouping. Please zip the project folder and post it.

The simplest code to just merge the files would be

Dim filelist() As String = {"d:\temp\don\20150228.txt", "d:\temp\don\20150301.txt", "d:\temp\don\20150302.txt"}

Dim sw As New System.IO.StreamWriter("d:\temp\don\out.txt", False)

For Each file As String In filelist

    Dim lines() As String = System.IO.File.ReadAllLines(file)

    For i = 0 To UBound(lines) - 4
        sw.WriteLine(lines(i))
    Next

Next

sw.WriteLine("")
sw.WriteLine("")
sw.WriteLine("                                                       End of Report")
sw.Close()

Note that I just dummied in three files. If you create a list of file names by scanning the folder and use the same loop then it should work no matter how many files are in the list.

ddanbe commented: Pro speaking here! +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Well, I just read an analysis of security holes in 2014 and according to the figures, the most holes were found in Mac IOS, next was Linux and in third place was Windows 7.

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

Ah. I see. I'm not familiar with that feature.

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

Microsoft has made many changes from Windows 7 to Windows 10. They redesigned the start menu (and made it worse) after having removed it in Windows 8. They've, yet again, rearranged everything so I have to go looking for the new locations, etc, etc. The thing I am absolutely the least concerned about is a new icon for the trash bin.

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

I don't know what you mean by a "shared" document.

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

I tried to test it as a shared file

What do you mean by that?

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

My advice is learn to walk before you learn to run. Get your code working simply before you complicate it with classes and overrides.

Nandomo commented: its not about doing it on this project, its about learning for the future +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You could iterate through the folder names and look for one starting with "1504 -".

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

I think your code would be a lot clearer, less prone to typos and easier to modify if you used intermediate variables. For example

DailyRate = arrDailyRates(cboBoard.SelectedIndex)

Select Case cboBoard.SelectedIndex

    Case 0 To 1

        If intDaysRented = 0 Then
            If intHoursRented > 3 Then
                cost = DailyRate
            Else
                cost = arrHourlyRates(cboBoard.SelectedIndex)
            End If              
        Else
            If intHoursRented > 3 Then
                cost = DailyRate * intDaysRented
            Else
                cost = DailyRate * intDaysRented + arrHourlyRates(0) * intHoursRented
            End If
        End If

    Case 2

        If intDaysRented = 0 Then
            If intHoursRented > 2 Then
                cost = DailyRate
            Else
                cost = arrHourlyRates(cboBoard.SelectedIndex) * intHoursRented
            End If
        Else
            If intHoursRented > 2 Then
                cost  = DailyRate * intDaysRented
            Else
                cost = DailyRate * intDaysRented + arrHourlyRates(2) * intHoursRented
            End If
        End If

    Case Else

        MsgBox("Something has gone terribly wrong with board selecting process.")
        End

End Select

lblCost.Text = FormatCurrency(cost, , TriState.True, TriState.True)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Based on his level of expertise, I would suggest NOT adding complexity by involving additional controls, especially ones that did not come with VB. Adding print statements (in this case Debug.WriteLine) is the simplest method.

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

Nothing in that code looks like it requires the complexity of a background thread, especially considering the ability of the OP. Debugging a single threaded program can be difficult enough.

Don - would it be possible for you to upload all three data files?

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

The usual approach is to add

Debug.WriteLine("stuff")

lines at strategic places inside the loop, then run the code to see what is happening. Either that or step through the code in the debugger with breakpoints.

By the way, a shorter method of adding a leading zero is the Format function as in

Dim month As String = Format(yesterday.Month, "00")
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You have to add adodb to the project.

Project -> Add Reference
.NET tab
Sort by component name
select adodb
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You could always just zoom out for the longer posts. That would effectively shrink the text down, then reset the zoom for the rest. For me that's a simple CTRL-WHEELSCROLL.

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

If you are using SQLEXPRESS (free), the database size is 10GB.

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

Buy anything but a Dell.

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

Try

SELECT  (SELECT SUM(total) FROM icm.sales)  AS branch1_sales,
        (SELECT SUM(total) FROM hism.sales) AS branch2_sales
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Use the USERNAME environment variables. On my machine with my current account it is

USERPROFILE=C:\Users\Jim

You can see the resulting command by

echo rd %USERPROFILE%\.digilabs\ubuildabook\data

If you use two backslashes before the "." when you post you get

C:\Users\PC\.digilabs\ubuildabook\data

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

Is your database set to use case sensitive strings? Try

SELECT COUNT(*) FROM route WHERE van = 'van1'
SELECT COUNT(*) FROM route WHERE van = 'Van1'

and see how many records are returned.

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

Try testdisk. It's free and open source. I haven't had the occasion to try it out but I've read good things about it. There is a step by step here.

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

Further research shows you should use the following...

Public Class Form1

    Declare Function Wow64DisableWow64FsRedirection Lib "kernel32" (ByRef oldvalue As Long) As Boolean
    Declare Function Wow64EnableWow64FsRedirection Lib "kernel32" (ByRef oldvalue As Long) As Boolean

    Private osk As String = "C:\Windows\System32\osk.exe"

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

        Dim old As Long

        If Environment.Is64BitOperatingSystem Then
            If Wow64DisableWow64FsRedirection(old) Then
                Process.Start(osk)
                Wow64EnableWow64FsRedirection(old)
            End If
        Else
            Process.Start(osk)
        End If

    End Sub

End Class

You want to wrap the invocation of osk.exe with disable/enable because disabling redirection affects all I/O operations in the current thread and you only want to disable it so that you can start osk.

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

Apparently it has to do with launching a 32 bit app (osk). Try the following...

Public Class Form1

    Declare Function Wow64DisableWow64FsRedirection Lib "kernel32" (ByRef oldvalue As Long) As Boolean

    Private osk As String = "C:\Windows\System32\osk.exe"

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

        Wow64DisableWow64FsRedirection(0)
        Process.Start(osk)

    End Sub

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

Just make sure that any block of text you write is terminated with a vbCrLf.

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

By the way, here is a handy regular expression tutorial

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

What you want to do is identify all occurrences of the word "go" (ignoring case) while ignoring any occurences of the string "go" that are embedded in a word. A regular expression will do that.

Imports System.Text.RegularExpressions

Public Class Form1

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

        Dim rex As New Regex("\bgo\b", RegexOptions.IgnoreCase)
        Dim str As String = "Please, go Mr. Gofer and good bye"

        For Each m As Match In rex.Matches(str)
            Debug.WriteLine(m.Index)
        Next

    End Sub

End Class

In a regular expression, the meta-character "\b" matches a word boundary so "\bgo\b" matches the word "go". The above loop will identify the starting position of each "go". In this case you want to replace two chars (go) with two chard (vbCrLf) so once you know the starting position of the word it should be a simple matter to write the code to do the substitution. Because you are replacing two chars with two chars, replacing the first occurrence will not affect the starting index of any remaining occurrences.

ddanbe commented: Nice. +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

This sounds like a homework question so I won't post the code but I can suggest that you use a regular expression to match "go" between two non-alphabetic characters.

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

You can find osk.exe in C:\Windows\System32. Run it and play with it. You will probably be able to avoid writing a lot of code.

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

Not a problem. When asked "do you know what time it is", it is easy to guess that the actual question is "what time is it." With code it is often easier to answer the question that was asked and forget the more lengthy "but what you should be doing is..." part. Especially, like now, when I have to type left handed because the cat wants attention ;-P

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

Perhaps if you explain what you are trying to do we can suggest how you might code it. You showed us the code but that only shows us what you coded, not what you are trying to accomplish. Your OP said only that you had a syntax error.

What I can suggest at the moment has nothing to do with your problem but will likely save you problems now and later. If your database field is numeric then make it numeric instead of string. That will likely save you storage space and a ton of conversion code which will help eliminate typos and make your code much clearer. Also, you will be able to embed calculations in the actual queries to do things like SUMS, etc.

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

Try

sql = "Update TBLORDERS " & 
      "   set qty   = qty   + ?," & 
      "       price = price + ?" & 
      " where nod = ?"

You were missing a comma.

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

If you mean a button from the on-screen keyboard then reread my post. However, I suspect you are meaning that you created your own keyboard. In that case you will need a class level variable to keep track of the last non-keyboard control that had focus. In the click event for a keyboard button you can add the clicked key text to the last textbox.

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

You might need to do it from the command prompt running as Administrator. Assuming your logonid is Eileen you will have to check both

C:\Users\Eileen\Desktop
C:\Users\All Users\Desktop

Do a dir from both locations. You should see the folder from one of them. Then use the rd folder /s /q command to remove it.

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

I'm not sure I see the problem. If you run osk.exe then click in a textbox to give it focus, whatever keys you click in osk will be sent to that textbox. If you want the keys to go to a different form or textbox then give that textbox focus.

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

Seems pretty subjective to me. I don't have a problem with it. Then again, my eyes are quite a bit older than yours so perhaps that has something to do with it.