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

Unfortunately, it's not just a question of being able to prove ownership. It's also being able to afford to prove ownership. If someone with deep pockets wants it then they can just tie you up in litigation until you are broke. That's why I think that once you've posted the code (the algorithm) you can pretty much say goodbye to ownership.

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

I think that once you've posted the code publicly you're pretty much SOL as to retaining control, legally or otherwise.

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

Create a ProgressBar named prgFileCopy and set

prgFileCopy.Minimum = 0

Calculate the number of files to be copied and assign that as

prgFileCopy.Maximum = numFiles

Start by setting

prgFileCopy.Value = 0

and after each file copy has completed (in the loop) do

prgFileCopy.Value += 1

You might want to dock the prgFilecopy to the bottom of the form.

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

I presume the error you got was regarding incorrect SQL syntax. You didn't post the error message. Without seeing the actual query, determining the problem will be, well, a problem. The actual query passed to the database engine depends on

  1. the constant strings like "UPDATE tbl_System" etc
  2. the strings you are patching in like TextBox2.Text

After the statement you posted, add

Debug.WriteLine(cmd.CommendText)

and post the output here.

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

If you declare class level integers nextRow and nextCol you can generate a new randow row and column by

Private Sub btnNumber_Click(sender As System.Object, e As System.EventArgs) Handles btnNumber.Click

    Dim rnd As New Random()
    Dim clicked As Boolean = True

    Do While clicked
        nextRow = rnd.Next(0, 4)
        nextCol = rnd.Next(0, 4)
        clicked = Grid(nextRow, nextCol).BackColor = Color.Red
        Me.Text = nextRow & "," & nextCol
    Loop

End Sub

The loop generates new pairs until it finds a pair for a cell that has not yet been clicked. You can modify the grid click handler to flip the colours only if the correct cell was clicked. You could even add

btnNumber.PerformClick()

as the last line in the grid click handler to automatically generate the next random pair.

By the way, Microsoft, for some insane reason, decided that the Next method would generate a random number which is greater than or equal to the lower bound but only less than the upper bound. This is a completely brain dead decision (IMHO). Thus rnd.Next(0,4) generates a number from 0 to 3.

Dark_1 commented: It's working... Thanks a lot... :) +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'm not sure I follow the logic but I'm going to offer a suggestion to see if that simplifies things. The user is expected to click on a textbox and "Click" is not an event associated with a textbox. It's more of a button thing. My suggestion is to create the grid at runtime and make it a grid of buttons. The buttons can be accessed through an array by the row and column numbers (0-3). Buttons, like textboxes, can have text and you can also change the colour.

Public Class Form1

    Private Grid(3, 3) As Button
    Private btnSize As Integer = 25
    Private btnPosn As New Point(10, 10)

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

        CreateGrid()

    End Sub

    Private Sub CreateGrid()

        'Create a 4x4 grid of buttons with a common event handler. References
        'to the buttons are stored in "Grid" for easy access. The row and
        'column numbers are stored in the button tags to differentiate the
        'individual buttons in the click handler.

        For row As Integer = 0 To 3
            For col As Integer = 0 To 3
                Dim xpos As Integer = btnPosn.X + btnSize * col
                Dim ypos As Integer = btnPosn.Y + btnSize * row
                Dim btn As New Button()
                btn.Tag = {row, col}
                btn.Location = New Point(xpos, ypos)
                btn.Size = New Size(btnSize, btnSize)
                AddHandler btn.Click, AddressOf Grid_Click
                Me.Controls.Add(btn)
                Grid(row, col) = btn
            Next
        Next

    End Sub

    Private Sub Grid_Click(sender As System.Object, e As System.EventArgs)

        Dim btn As Button = sender …
Dark_1 commented: Actually It should be able to press only the number specified in the Random Generator. If he clicked the right one colour changes if else no change +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

At ConnectionStrings.com the string for Access 2013 (standard security) is

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;Persist Security Info=False;

Try specifying the fully qualified file name for the database. It also might help (more info) if you comment out the try/catch logic and get the actual error message instead of masking it with your own.

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

OK. Then the obvious next question is - what is the type of the database field named playerid. I had assumed it was numeric based on the single example. Please note that I have asked you three times to post the actual query (the value of cmd.CommandText) and you still haven't done that.

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

And what are you having a problem with? You haven't said what kind of database you are using or what language you are programming in. Is your problem with the database design or the queries? Is your problem with the connection string? Show us what you have so far. If it's a database question then this is the place for it. If it's a programming problem then post it in the appropriate language forum.

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

In this case it doesn't matter what your code is. The error is in the query and showing us

cmd.CommandText = cmd.CommandText = "SELECT health,strength FROM playerstats WHERE playerid= " & playeridlbl.Text

doesn't tell us what the query is because we don't know the value of playeridlbl.Text. If you won't post the actual query (ie the value of cmd.CommandText) then we can't help you.

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

I don't see any output from Debug.Writeline. Comment out the Try/Catch/End Try.

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

Try

cmd.CommandText = "SELECT health,strength FROM playerstats " &
                  " WHERE playerid=" & playeridlbl.Text
Debug.WriteLine cmd.CommandText

and post the output here.

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

That looks right, however because your playerid is numeric you should leave out the single quotes and use

cmd.CommandText = "SELECT health,strength FROM playerstats " &
                  " WHERE playerid=" & playeridlbl.Text

You were comparing a numeric field 1 with the string '1'. At least I am assuming playeridlbl.Text had the value "1".

Again, you will find working with databases (and composing queries) much easier if you install SQL Management Studio.

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

Do you have SQL Management Studio (SQLMS) installed? It's free from Microsoft and is really useful for developing data base based apps. If not then I suggest a breakpoint at the first line of

reader = cmd.ExecuteReader()
While reader.Read = True
    healthlbl.Text = reader.Item(1).ToString()
    strengthlbl.Text = reader.Item(2).ToString()
End While

Check the exact query text and make sure your query is actually returning a record with values. With SQLMS you could execute the query in an ad hoc window and check the results. I strongly suggest you install it.

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

Fields are zero-relative. You could index them by (using the correct syntax)

healthlbl.Text = reader(0)
strengthlbl.Text = reader(1)

but this is bad practice because if you change the query you might brreak the code. You should, instead, index using the field name as in

healthlbl.Text = reader("health")
strengthlbl.Text = reader("strength")

Note that the second form works whether the query does any of the following:

SELECT health, strength
SELECT strength, health
SELECT *

Because the fields health and strength are already strings you do not need to do ToString.

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

One time I was able to recover the text only from a corrupt word file by using strings.exe which is available as a free SysInternals tool. That program will extract all text strings from any file. If the file is compressed then you are likely out of luck.

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

Try clearing your cache and reloading the page.

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

It's like using an index at the back of a book to get the page (address) of a particular topic. Instead of scanning the book looking for the topic you just get the address from the index and go directly there. You can add an index for any field (or combination of fields) but with every index you add there is a penalty in that it requires extra space for the index and extra processing time to maintain the index.

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

As far as I know the only way to get your encrypted adta back is to pay the ransom. Typically you are given a set number of days to pay the ransom. If you don't pay it before the deadline you are screwed. Removing the virus has the same effect as missing the deadline. It's sort of like in the movies when the hero cuts the wrong bomb wire and the timer fast-forwards to zero.

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

Try

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

You may also want to have a look at this code snippet.

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

The easiest way to separate out numbers delimited by one or more blanks is with a regular expression. Here is a sample

Imports System.Text.RegularExpressions

Public Class Form1

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

        Dim rex As New Regex("[0-9]+")
        Dim line As String = "   123     45    67   89   "

        For Each m As Match In rex.Matches(line)
            Debug.WriteLine(m.Value)
        Next

    End Sub

End Class

The expression [0-9]+ matches the longest possible string of digits. This works whether the delimiters are blanks, commans, or whatever. The caveat is that this works only on integers. If you want to include numbers with a decimal point use the pattern [0-9\.]+. To allow for an optional leading sign use [-+]*[0-9\.]+.

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

By default, the Excel app is open invisible. It will only show if you set Visible to True.

I've mentioned arrays before. To set the column headers you might do

Dim headers() As String = {"Prop ID", "Arrival Date", "Departure Date",
                           "Booking Date", "Room Type", "Rate Plan",
                           "Rate", "Payment Type", "Guest Name", "Group",
                           "Source"}

For col As Integer = 0 To UBound(headers)
    xlWorkSheet.Cells(1, col + 1) = headers(col)
Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'd try this out locally but there are too many things missing. You have a number of variables such as propertyNo bookingDate and saveRestran, not to mention a few control variables like newResOnly that just cause the whole thing to fall apart.

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

I realize that but

Dim num As Integer = CInt(some string)
Dim pt1 As Integer = num Mod 1000
Dim pt2 As Integer = num \ 1000

is clearer than substringing since it's a numerical problem, and you don't have to account for varying numbers of digits (and calculating string lengths and offsets). The code could be put into a Function which would also check to make sure the string is an integer value.

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

Just a thought - I think you would be better off parsing the numbers as integers rather than strings. To get the two "parts" of a number you can do

num Mod 1000   'for num = 98765 this results in 765
num \ 1000     'for num = 98765 this results in 98

This works for any positive integer and you don't have to worry about substring errors.

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

Do

StateSQL = "SELECT * FROM petrol_table " &
           " WHERE fueldate >= " & "'" & M12S & "'" & 
           "   AND fueldate <  " & "'" & M12F & "'"
Debug.WriteLine(StateSQL)

and post the output here.

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

Try

StateSQL = "SELECT * FROM petrol_table " &
           " WHERE fueldate >= @sdate    &
           "   AND fueldate <  @edate"
Conn.Open()
sqlCmd = New SqlCommand(StateSQL, Conn)
sqlCmd.Parameters.AddWithValue("@sdate", M12S)
sqlCmd.Parameters.AddWithValue("@edate", M12F)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Is it only one one particular project or does it also happen on a new project? If just the one then you may have to recreate it from scratch and copy the code in to the new code window. If that doesn't work you may have to uninstall/reinstall Visual Studio.

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

You get the selected node through

TreeView1.SelectedNode

You can select a specific node in code by

TreeView1.SelectedNode = TreeView1.Nodes(0).Nodes(4)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You are not using IIF correctly. You can not execute statements within an IIF. For example

Dim a As Integer = 1
Dim b As Integer = 2
Dim c As Integer = 3

IIf(a = 1, b = 7, b = 8)

b will still have the value 2, however, if you do

b = IIf(a = 1, 7, 8)

then b will have the value 7. You could rewrite your statements as

If Me.cmbwkdays.SelectedItem = Nothing) Then
    Cmd.Parameters.AddWithValue("@DayNos", "N/A")
Else
    Cmd.Parameters.AddWithValue("@DayNos", Me.cmbwkdays.SelectedItem)
End If

or you could do

Dim temp As String = IIf(Me.cmbwkdays.SelectedItem = Nothing, "N/A", Me.cmbwkdays.SelectedItem))
Cmd.Parameters.AddWithValue("@DayNos", temp)

Also, I counted twice but it looks like you have 29 field names and 29 AddWithValue statements but only 28 "?".

Santanu.Das commented: I'm grateful to you for all your help. +5
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Yeah. It was ambiguous but considering that the number of displayed lines would vary depending on the size of the form I assumed hard terminated lines as the more likely scenario.

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

@rproffitt - the code I suggested allows all of that. It says only to disallow any ENTER keys if already at the max allowed. All other keystrokes are still allowed.

@satyam_1 - please explain how the code does not meet your needs and I will try to modify it accordingly.

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

Have you tried stepping through the code in the debugger?

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

Sorry. Didn't check the modified query. You have to also select Fullname, not just EmpID. You can only reference columns that you have selected.

selectQuery = "SELECT EmpID, FullName...
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

In that case try

If dr.Read Then
    txtEmpName.Text = dr("FullName")

Keep in mind that because you are doing a "Like" in the select query you may end up with more than one matching record (depending on whether txtEmpId.Text contains wildcards)

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

Your query is

"SELECT * FROM EmployeeRegistration WHERE EmpID Like '" + txtEmpId.Text + "' AND FullName = '" & txtEmpName.Text & "'"

so you are going to select based on an employee ID and full name that you already have displayed. If you already have the full name why do you need to redisplay it from the database?

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

You already have the employee ID in txtEmpId and the employee name in txtEmpName before you click SEARCH. What am I missing?

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

Try the KeyDown event instread

Private Sub RichTextBox1_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown

    If e.KeyCode = Keys.Enter And RichTextBox1.Lines.Count = MAXLINES Then
        e.SuppressKeyPress = True
    End If

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

I suppose you have already noticed this but composing a query by concatenating multiple strings is just butt ugly. For one thing you have to keep track of where to add single quotes and where not to.

The first thing I can suggest is to use the full INSERT syntax in which you explicitly state the column names as in

INSERT INTO tablename (fld1, fld2, ... fldn)
    VALUES (val1, val2, ... valn)

The second thing is to use Parameterized Queries. Please refer to the Sub btnSQLDB_Click.

Because you are using SqlClient you can use named parameters that are not dependent on position. If you copy your TextBox values to appropriately typed local variables appropriate delimiters will be added automatically.

Santanu.Das commented: Perfect suggetion +5
cudawella commented: thank you very much +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Please post the new code and this time identify the line that is raising the error.

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

What line is giving the error? By the way, you may want to open the connection before you try to use it.

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

You can't get that toolstrip from the given pseudo-xml. You might as well have posted

<Buttons>
    <tag>Some Buttons</tag>
</Buttons>
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

How about posting the xml and an example of what you want the tool strip to look like?

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

You could try to reference the file as

\\machine\D$\file.pdf

This assumes that the server has access to your PC using the admin share. If not then you may need to set up a share (probably read only) to a folder set up strictly for that purpose.

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

It's a small seven-legged marsupial.

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

When used as a single statement

iNumber = 1

assigns 1 to iNumber. When used as a conditional it evaluates to a Boolean which is actually 0 or -1 so

If IsNumeric(iNumber = 1) Then

will always evaluate to True no matter what number you compare iNumber to. One alternative is

Dim iNumber As Integer = 1
Dim sNumber As String = InputBox("Enter a number", "Numbers Only", iNumber)

If IsNumeric(sNumber) Then

    iNumber = CInt(sNumber)

    If iNumber >= 1 And iNumber <= 5 Then

        For i As Integer = 1 To iNumber
            Me.Controls("GroupBox" & i).Visible = True
        Next

    Else
        MsgBox("Enter only numbers from 1 to 5")
    End If
Else
    MsgBox("Enter only numbers from 1 to 5")
End If
ddanbe commented: Yes, of course. +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You keep changing formats. First you said

Ani      | Human, my friend, boy

Now the format is

Ani #friend #human #male

The first thing you have to do is nail down a format. I'm guessing that what you have is a file like

Ani      | Human, my friend, boy
Car      | Vehicle, object with 4 wheels
Truck    | Vehicle, object with 4 wheels
Play     | Enjoyment
Man      | Human, male
Woman    | Human, female

That would be easy to parse. You could use Split on | to separate the word from the tags, then Split on , to separate the individual tags.

Based on that, when you type a tag into a textbox the program displays all words from the file that have that tag. For example, if you enter Vehicle, the program will display

Car
Truck

Is that correct?

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

I have a few unrelated suggestions.

You might want to replace the multiple declarations of prop## with

Private prop(30)

This would allow you to replace

prop01 = tbxProperty01.Text
lblProperty01.Text = prop01
prop02 = tbxProperty02.Text
lblProperty02.Text = prop02
prop03 = tbxProperty03.Text
lblProperty03.Text = prop03
prop04 = tbxProperty04.Text
lblProperty04.Text = prop04
prop05 = tbxProperty05.Text
lblProperty05.Text = prop05
prop06 = tbxProperty06.Text
lblProperty06.Text = prop06
prop07 = tbxProperty07.Text
lblProperty07.Text = prop07
prop08 = tbxProperty08.Text
lblProperty08.Text = prop08
prop09 = tbxProperty09.Text
lblProperty09.Text = prop09
prop10 = tbxProperty10.Text
lblProperty10.Text = prop10
prop11 = tbxProperty11.Text
lblProperty11.Text = prop11
prop12 = tbxProperty12.Text
lblProperty12.Text = prop12
prop13 = tbxProperty13.Text
lblProperty13.Text = prop13
prop14 = tbxProperty14.Text
lblProperty14.Text = prop14
prop15 = tbxProperty15.Text
lblProperty15.Text = prop15
prop16 = tbxProperty16.Text
lblProperty16.Text = prop16
prop17 = tbxProperty17.Text
lblProperty17.Text = prop17
prop18 = tbxProperty18.Text
lblProperty18.Text = prop18
prop19 = tbxProperty19.Text
lblProperty19.Text = prop19
prop20 = tbxProperty20.Text
lblProperty20.Text = prop20
prop01 = tbxProperty01.Text
lblProperty21.Text = prop21
prop22 = tbxProperty22.Text
lblProperty22.Text = prop22
prop23 = tbxProperty23.Text
lblProperty23.Text = prop23
prop24 = tbxProperty24.Text
lblProperty24.Text = prop24
prop25 = tbxProperty25.Text
lblProperty25.Text = prop25
prop26 = tbxProperty26.Text
lblProperty26.Text = prop26
prop27 = tbxProperty27.Text
lblProperty27.Text = prop27
prop28 = tbxProperty28.Text
lblProperty28.Text = prop28
prop29 = tbxProperty29.Text
lblProperty29.Text = prop29
prop30 = tbxProperty30.Text
lblProperty30.Text = prop30

with

For i As Integer = 1 To 30
    Dim seq As String = i.ToString("D2")
    Dim tbx As TextBox = Me.Controls("tbxProperty" & seq)
    Dim lbl As Label = Me.Controls("lblProperty" & seq)
    prop(i) = tbx.Text
    lbl.Text = prop(i)
Next

or, …

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

I don't see how we can help without seeing the code.