cgeier 187 Junior Poster

I haven't ever tried it, but this article talks about it. Click "Project" => "Add Reference" => "Browse" => <your dll> => "OK".

Then add Imports YourDLL

Create an instance of your class and call the method to show the form.

cgeier 187 Junior Poster

Yes. My mistake.

cgeier 187 Junior Poster

Also one of your for loops is missing a "{"

cgeier 187 Junior Poster

Backup your favorites from "C:\Users\<username>\Favorites" to somewhere else. Un-install IE 11. Reboot. Then re-install IE 11.

Also run a chkdsk on your hard drive. Start => Computer => Right-click "C:" => and select "Properties", Tools => Check Now = > select both checkboxes => Start

cgeier 187 Junior Poster

Your question is unclear. Are you trying to write a batch script? If so, you should probably post it in "Shell Scripting".

cgeier 187 Junior Poster
cgeier 187 Junior Poster

Use a keyboard hook. Click Here for an article about mouse hooks and keyboard hooks.

cgeier 187 Junior Poster

The driver name has a space in the name that should not be there. Remove the space after *.accdb.

Change driver from:

Driver={Microsoft Access Driver (*.mdb, *.accdb )};

To:

Driver={Microsoft Access Driver (*.mdb, *.accdb)};
cgeier 187 Junior Poster

Add a "WebBrowser" control to your current form (or create a second form and add it to that form). Then use "Navigate". Change the "Dock" and "Anchor" properties of the WebBrowser control as needed to fit properly and resize properly on your form.

Call webBrowser1.Navigate("myurl.com") in the "LinkClicked" event (of your LinkLabel control).

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
     webBrowser1.Visible = true;
     webBrowser1.Navigate("http://myUrl.com");

}
cgeier 187 Junior Poster

The code I provided is basic, mostly repetative. Using dictionary is far more complex than the solution I provided. My code really only introduces 3 questions.

  1. What is a list and how do I use it?
  2. What is a property and how do I use it?
  3. What is a class and how do I use it?
cgeier 187 Junior Poster

You might consider using a class with Property values.

Quiz.vb

Public Class Quiz

    Private _question As String
    Private _answer As String
    Private _randomAnswer1 As String
    Private _randomAnswer2 As String
    Private _randomAnswer3 As String
    Private _numberOfTimesCompleted As Integer

    Public Sub New()

    End Sub

    Public Sub New(ByVal Question As String, _
                    ByVal Answer As String, _
                    ByVal RandomAnswer1 As String, _
                    ByVal RandomAnswer2 As String, _
                    ByVal RandomAnswer3 As String, _
                    ByVal NumberOfTimesCompleted As Integer)

        _question = Question
        _answer = Answer
        _randomAnswer1 = RandomAnswer1
        _randomAnswer2 = RandomAnswer2
        _randomAnswer3 = RandomAnswer3
        _numberOfTimesCompleted = NumberOfTimesCompleted

    End Sub

    Public Property Question As String
        Get
            Return _question
        End Get

        Set(value As String)
            _question = value
        End Set
    End Property 'Question

    Public Property Answer As String
        Get
            Return _answer
        End Get

        Set(value As String)
            _answer = value
        End Set
    End Property 'Answer

    Public Property RandomAnswer1 As String
        Get
            Return _randomAnswer1
        End Get

        Set(value As String)
            _randomAnswer1 = value
        End Set
    End Property 'RandomAnswer1

    Public Property RandomAnswer2 As String
        Get
            Return _randomAnswer2
        End Get

        Set(value As String)
            _randomAnswer2 = value
        End Set
    End Property 'RandomAnswer2

    Public Property RandomAnswer3 As String
        Get
            Return _randomAnswer3
        End Get

        Set(value As String)
            _randomAnswer3 = value
        End Set
    End Property 'RandomAnswer3

    Public Property NumberOfTimesCompleted As Integer
        Get
            Return _numberOfTimesCompleted
        End Get

        Set(value As Integer)
            _numberOfTimesCompleted = value
        End Set
    End Property 'NumberOfTimesCompleted

End Class

Usage:

Dim myQuiz As Quiz
Dim myQuizList As New List(Of Quiz)

Dim question As String = String.Empty
Dim answer As String = String.Empty
Dim randomAnswer1 As …
cgeier 187 Junior Poster

I recommend using some useful names so it is easier to follow your code. Use something like "height", "startWeight", "endWeight" instead of "t1", "t2", "t3".

I suggest that you use the following form of the for loop:

double startWeight = 60;
double endWeight = 125;

double weight = startWeight;

for (weight = startWeight; weight <= endWeight; )
{
    //rest of your code here


    //increment weight
    weight = weight + 5;
}//for
cgeier 187 Junior Poster

Your question is not clear. What are you trying to do?

cgeier 187 Junior Poster

You probably aren't going to receive many responses without posting your code.

cgeier 187 Junior Poster

I don't really know anything specifically about Groovy--just some general regular expression stuff. Here is a resource that I found for Groovy.

cgeier 187 Junior Poster

You probably need to add this after line 23:

cmd = New SqlCommand()

so your code will be:

conn = New OleDbConnection(Get_Constring)
conn.Open()

cmd = New SqlCommand()
cmd.Connection = conn

but it is hard to know for sure because you didn't post the rest or your variable declarations.

Also, add this to your Try-Catch:

Catch ex As System.Data.OleDb.OleDbException
    MsgBox(ErrorToString)
cgeier 187 Junior Poster

Before, I didn't have time to properly test the code. This one has been tested and hopefully will work for you. I've added some error checking to it.

Use "Client.vb" from my previous post.

To use it you will need a form called "Form1.vb".

Add Imports System.Xml

On "Form1" you need to add the following:

  • add a combobox named: ComboBox1
  • add event "SelectedValueChanged or "SelectedIndexChanged" to ComboBox1 (the code below contains both, but you only need to use one of them)
  • add a textbox named: errorWordsTextBox
  • add a textbox named: falseWordsTextBox

Double-click the form to create "Form1_Load".

Note: The node names are case-sensitive. "Clients" (upper-case first letter) is different from "clients" (all lower-case).

Form1.vb

Imports System.Xml

'To use this:
'add a combobox named: ComboBox1
'add a textbox named: errorWordsTextBox
'add a textbox named: falseWordsTextBox

Public Class Form1
    Dim myList As List(Of Client) = New List(Of Client)

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

        'change this to your filename
        myList = readXmlFile("C:\temp\client.xml")

        'where ComboBox1 contains "name"
        'where errorWordsTextBox contains "errorWords"
        'where falseWordsTextBox contains "falseWords"

        ComboBox1.Items.Clear()
        For Each yourClient As Client In myList
            ComboBox1.Items.Add(yourClient.Name)
            'Console.WriteLine("Id: " + yourClient.Id)
        Next
    End Sub

    Private Function readXmlFile(ByVal filename As String) As List(Of Client)
        Dim doc As New Xml.XmlDocument
        Dim myClientList As New List(Of Client)
        Dim myClient As Client = New Client()

        If Not (System.IO.File.Exists(filename)) Then
            MessageBox.Show(filename + " not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Return myClientList 'exit function
        End If

        Try
            'load XML document
            doc.Load(filename)

            Dim xmlName As Xml.XmlNode
            Dim xmlSender …
cgeier 187 Junior Poster

When I pasted it, I may have missed a couple of lines. My apologies.

Need to add Imports System.Xml

Uses the "Client.vb" class from above.

    Private Function readXmlFile(ByVal filename As String) As List(Of Client)
        Dim doc As New Xml.XmlDocument
        Dim myClientList As New List(Of Client)
        Dim myClient As Client

        doc.Load("C:\temp\client.xml")

        Dim xmlName As Xml.XmlNode
        Dim xmlSender As Xml.XmlNode
        Dim xmlErrorWord As Xml.XmlNode
        Dim xmlFalseWord As Xml.XmlNode
        Dim xmlLink As Xml.XmlNode
        Dim xmlDay As Xml.XmlNode
        Dim xmlClientNodeList As Xml.XmlNodeList

        xmlClientNodeList = doc.SelectNodes("//clients/client")

        For Each myNode As Xml.XmlNode In xmlClientNodeList
            If Not (myNode.Attributes Is Nothing) Then
                For Each myAttrib As Xml.XmlAttribute In myNode.Attributes
                    If (String.Compare(myAttrib.Name, "id") = 0) Then

                        'intialize new client
                        myClient = New Client()
                        Console.WriteLine(myAttrib.Name + ":" + myAttrib.Value)
                    End If
                Next
            End If

            xmlName = doc.SelectSingleNode("/clients/client/name")
            If Not (xmlName Is Nothing) Then
                myClient.Name = xmlName.InnerText
                Console.WriteLine(xmlName.Name + ": " + xmlName.InnerText)

            End If

            xmlSender = doc.SelectSingleNode("/clients/client/sender")
            If Not (xmlSender Is Nothing) Then
                myClient.Sender = xmlSender.InnerText
                Console.WriteLine(xmlSender.Name + ": " + xmlSender.InnerText)
            End If

            xmlErrorWord = doc.SelectSingleNode("/clients/client/errorWords")
            If Not (xmlSender Is Nothing) Then
                myClient.ErrorWords = xmlErrorWord.InnerText
                Console.WriteLine(xmlErrorWord.Name + ": " + xmlErrorWord.InnerText)
            End If

            'add the rest here

            'add client to arraylist
            myClientList.Add(New Client(myClient.Id, myClient.Name, myClient.Sender, _
                                        myClient.ErrorWords, myClient.FalseWords, _
                                        myClient.Link, myClient.Days))
        Next

        Return (myClientList)
    End Function

Usage:

    Dim myList As List(Of Client) = readXmlFile("C:\temp\client.xml")

    'where ComboBox1 contains "name"
    'where ComboBox2 contains "errorWords"

    ComboBox2.Items.Clear()
    For Each yourClient As Client In myList

        'if this is the one the user selected
        'add data to the second combobox …
cgeier 187 Junior Poster

Ok. Here is a better way of doing it.

        Dim xmlName As Xml.XmlNode
        Dim xmlSender As Xml.XmlNode
        Dim xmlErrorWord As Xml.XmlNode
        Dim xmlFalseWord As Xml.XmlNode
        Dim xmlLink As Xml.XmlNode
        Dim xmlDay As Xml.XmlNode
        Dim xmlClientNodeList As Xml.XmlNodeList

        xmlClientNodeList = doc.SelectNodes("//clients/client")

        For Each myNode As Xml.XmlNode In xmlClientNodeList
            If Not (myNode.Attributes Is Nothing) Then
                For Each myAttrib As Xml.XmlAttribute In myNode.Attributes
                    If (String.Compare(myAttrib.Name, "id") = 0) Then
                        Console.WriteLine(myAttrib.Name + ":" + myAttrib.Value)
                    End If
                Next
            End If

            xmlName = doc.SelectSingleNode("/clients/client/name")
            If Not (xmlName Is Nothing) Then
                Console.WriteLine(xmlName.Name + ": " + xmlName.InnerText)
            End If

            xmlSender = doc.SelectSingleNode("/clients/client/sender")
            If Not (xmlSender Is Nothing) Then
                Console.WriteLine(xmlSender.Name + ": " + xmlSender.InnerText)
            End If


            'add the rest here

        Next

Then add them to a List (of Client) below where it says 'add the rest here' (or a Dictionary).

cgeier 187 Junior Poster

I've attached the files. Once the data is in a list, you can just search the list. Or you could probably put the data into a dictionary. Then in the combobox, use the "SelectedValueChanged" or "SelectedIndexChanged" event.

cgeier 187 Junior Poster

There may be a simpler solution, but this one will work:

Client.vb

Public Class Client
    Private _id As String = String.Empty
    Private _name As String = String.Empty
    Private _sender As String = String.Empty
    Private _errorWords As String = String.Empty
    Private _falseWords As String = String.Empty
    Private _link As String = String.Empty
    Private _days As String = String.Empty

    Public Sub New()

    End Sub

    Public Sub New(ByVal id As String, ByVal name As String, _
                   ByVal sender As String, ByVal errorWords As String, _
                   ByVal falseWords As String, ByVal link As String, ByVal days As String)

        _id = id
        _name = name
        _sender = sender
        _errorWords = errorWords
        _falseWords = falseWords
        _link = link
        _days = days
    End Sub


    Public Property Id As String
        Get
            Return _id
        End Get

        Set(value As String)
            _id = value
        End Set
    End Property 'Id

    Public Property Name As String
        Get
            Return _name
        End Get

        Set(value As String)
            _name = value
        End Set
    End Property 'Name

    Public Property Sender As String
        Get
            Return _sender
        End Get

        Set(value As String)
            _sender = value
        End Set
    End Property 'Sender

    Public Property ErrorWords As String
        Get
            Return _errorWords
        End Get

        Set(value As String)
            _errorWords = value
        End Set
    End Property 'ErrorWords

    Public Property FalseWords As String
        Get
            Return _falseWords
        End Get

        Set(value As String)
            _falseWords = value
        End Set
    End Property 'FalseWords

    Public Property Link As String
        Get
            Return _link
        End Get

        Set(value As String)
            _link = value
        End Set
    End Property 'Link

    Public Property Days As String
        Get …
cgeier 187 Junior Poster

This post may help you: Click Here

cgeier 187 Junior Poster

Click on "</> Code" and paste using Ctl-v.

cgeier 187 Junior Poster

You could use an Access database. Or XML (xmlreader and xmlwriter). Or just put it in a plain text file like you've done.

Since this is for a class, you can probably do whatever you want, as it is unlikely that you will have that many records. You just need to use 1 or more unique characters as separators. As long as your not accepting Euros (or some other currency that uses commas) you should be fine.

It is unlikely that the file needs to be easily readable, I would only use an blank line to separate records or elmininate blank lines because it will reduce the size of your file. You want something you can easily split the string on--such as a comma. Think of a .csv (comma-delimited) file.

Here's a slight modification (changed first colon to a comma):

    Order Number: 1
    Customer #1: Harrington, Honor
    Ice Cream Cone, Scoops: 1, Cone Cost: $1.25, Pickle  
    Ice Cream Cone, Scoops: 1, Cone Cost: $1.25, Tangarine   
    Ice Cream Cone, Scoops: 1, Cone Cost: $1.25, Nectarine  
    Ice Cream Cone, Scoops: 1, Cone Cost: $1.25, Orange   
    Ice Cream Cone, Scoops: 1, Cone Cost: $1.25, Chocolate   
    Ice Cream Cone, Scoops: 1, Cone Cost: $1.25, Fudge  
    Yogurt Cone, Scoops: 1, Cone Cost: $1.25, Pickle  
    Yogurt Cone, Scoops: 1, Cone Cost: $1.25, Tangarine  
    Yogurt Cone, Scoops: 1, Cone Cost: $1.25, Nectarine   
    Yogurt Cone, Scoops: 1, Cone Cost: $1.25, Orange  
    Total Price: $12.50

    Order Number: 2
    Customer #1: Harrington, John
    Ice Cream Cone, Scoops: 1, …
cgeier 187 Junior Poster

I think Reverend Jim found your error. An update to my post. I incorrectly converted to decimal. Line 7 in "Usage" should be Decimal.TryParse(TextBox1.Text, myVal1) instead of myVal1 = Convert.ToDecimal(TextBox1).

Also, you may consider doing some error handling:

    Dim sqlText as String
    Dim sqlCmd As SqlCommand

    Try

        .......

        sqlText = @"INSERT INTO myTable(col1, col2) VALUES(@myVal1, @myVal2)"

        .......

    Catch ex As System.Data.SqlClient.SqlException
            Console.WriteLine(ex.Message + " (SQL: " + query + ")")

            'if using OleDb
    Catch ex As System.Data.OleDb.OleDbException
        Console.WriteLine(ex.Message + " (SQL: " + sqlText + ")")

    Catch ex As Exception
        Console.WriteLine(ex.Message + " (SQL: " + sqlText + ")")
    Finally
        sqlCmd.Dispose()
    End Try
cgeier 187 Junior Poster

What tables? Join your tables in your select statement. Need more information about the table structures. You haven't shown that you've made any attempt. Where's your code?

cgeier 187 Junior Poster

Chrome supports HTML5. I don't believe HTML5 was (fully) implemented in IE 8. Upgrade your browser.

HTML5 Browser Tester

If it is your website, you may be able to modify your web pages: HTML5 enabling script for IE

cgeier 187 Junior Poster

I left out some things in my previous post. Try this:

Add Imports System.Data.SqlClient

    Private Sub insertMyTable(ByRef conn As SqlConnection, ByVal myVal1 As Decimal, ByVal myVal2 As String)

        Dim sqlCmd As SqlCommand
        Dim sqlText As String

        If (conn.State <> System.Data.ConnectionState.Open) Then
            conn.Open()
        End If

        sqlCmd = New SqlCommand()

        sqlText = @"INSERT INTO myTable(col1, col2) VALUES(@myVal1, @myVal2)"
        sqlCmd.Connection = conn
        sqlCmd.CommandText = sqlText

        Dim paramName0 As SqlParameter
        paramName0 = New SqlParameter()

        paramName0.SqlDbType = SqlDbType.Decimal
        'paramName0.SqlDbType = SqlDbType.Float
        'paramName0.SqlDbType = SqlDbType.Int
        'paramName0.SqlDbType = SqlDbType.Money
        paramName0.Direction = ParameterDirection.Input
        paramName0.Value = myVal1
        sqlCmd.Parameters.Add(paramName0)

        Dim paramName1 As SqlParameter
        paramName1 = New SqlParameter()
        paramName1.SqlDbType = SqlDbType.VarChar
        paramName1.Direction = ParameterDirection.Input

        If (myVal2 Is Nothing) Then
            paramName1.Value = DBNull.Value
        Else
            paramName1.Value = myVal2
        End If

        sqlCmd.Parameters.Add(paramName1)

        sqlCmd.ExecuteNonQuery()
    End Sub

Usage:

        Dim conn As SqlConnection
        conn = New SqlConnection("Server=GEN-PC;Data Source=GEN-PC\SQLEXPRESS;Initial Catalog=Brgy;Integrated Security=True;")

        Dim myVal1 As Decimal
        Dim myVal2 As String

        myVal1 = Convert.ToDecimal(TextBox1)
        myVal2 = TextBox2.Text

        insertMyTable(conn, myVal1, myVal2)

Alternatively you could use sqlCmd.Parameters.AddWithValue("@myVal1", myVal1). The important thing is to make sure "myVal1" is the correct data type before passing it to the statement. This version may cause implicit data conversions during insert which may cause performance issues.

cgeier 187 Junior Poster

You're still passing "string" data.

    Private Sub insertMyTable(ByRef conn As SqlConnection, ByVal myVal1 As Decimal, ByVal myVal2 As String)

        Dim sqlCmd As SqlCommand

        Dim sqlText As String

        sqlCmd = New SqlCommand()

        sqlText = @"INSERT INTO myTable(col1, col2) VALUES(@myVal1, @myVal2)"

        Dim paramName0 As SqlParameter
        paramName0 = New SqlParameter()

        paramName0.SqlDbType = SqlDbType.Decimal
        'paramName0.SqlDbType = SqlDbType.Float
        'paramName0.SqlDbType = SqlDbType.Int
        'paramName0.SqlDbType = SqlDbType.Money
        paramName0.Direction = ParameterDirection.Input
        paramName0.Value = myVal1
        sqlCmd.Parameters.Add(paramName0)

        Dim paramName1 As SqlParameter
        paramName1 = New SqlParameter()
        paramName1.SqlDbType = SqlDbType.VarChar
        paramName1.Direction = ParameterDirection.Input
        paramName1.Value = myVal2
        sqlCmd.Parameters.Add(paramName1)

        sqlCmd.ExecuteNonQuery()
    End Sub
cgeier 187 Junior Poster

I can't remember if the webbrowser control supports javascript. The other issue could be with cookies.

Here's some stuff I've used:

using System.Runtime.InteropServices;
using Microsoft.Win32;
using mshtml; //internet - Reference => .NET = Microsoft.mshtml
using SHDocVw; //internet - Reference => COM  => Microsoft Internet Control
using System.Net; //HttpWebRequest, HttpWebResponse
using System.Security.Cryptography;

//It works with websites that have HTTPONLY set for cookies.
//it is necessary to use SHDocVw for this though, as   
//System.Windows.Forms.WebBrowser 
//doesn't seem to work as desired. 

//make a commom instance of WebBrowser
public SHDocVw.InternetExplorer myWebBrowser = new SHDocVw.InternetExplorer(); 

//used to pass cookies from myWebBrowser
private System.Net.CookieContainer cookies = new System.Net.CookieContainer();

//----------------------------------------
// used to get HTTPONLY cookies 
//----------------------------------------
const int INTERNET_COOKIE_HTTPONLY = 0x00002000;

[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool InternetGetCookieEx(string pchURL, string pchCookieName, StringBuilder pchCookieData, ref uint pcchCookieData, int dwFlags, IntPtr lpReserved);

Then you can use the following in the documentComplete event:

//set htmlData
HTMLDocument doc = (mshtml.HTMLDocument)myWebBrowser.Document;
string htmlData = doc.body.outerHTML;

Here is setting cookies in the NavigateComplete2 event:

private void myWebBrowser_NavigateComplete2(object sender, ref object URL)
{

    //Console.WriteLine("Navigate complete: " + URL.ToString());
    mshtml.IHTMLDocument2 HTMLDocument = (mshtml.IHTMLDocument2)myWebBrowser.Document;

    try
    {
        //add cookies to cookie container
        this.cookies.SetCookies(new Uri(URL.ToString()), HTMLDocument.cookie);
    }//try
    catch (Exception ex)
    {
        Console.WriteLine("ERROR: WebSHDocVw::myWebBrowser_Navigating (SetCookies): " + ex.Message);
    }//catch

    try
    {
        //add readonly cookies to cookie container
        this.cookies.SetCookies(new Uri(URL.ToString()), this.GetGlobalCookies(URL.ToString()));
    }//try
    catch (Exception ex)
    {
        Console.WriteLine("ERROR: WebSHDocVw::myWebBrowser_Navigating (SetCookies - Global): " + ex.Message);
    }//catch
}//myWebBrowser_NavigateComplete2
cgeier 187 Junior Poster

Did you check out DataGridView.IsCurrentRowDirty

"This property returns true when the pencil glyph is displayed in the row. By default, the IsCurrentRowDirty property will always equal the value of the IsCurrentCellDirty property, unless the DataGridView is bound to a data source that supports editing, or virtual mode has been implemented to use row-level commit scope. In these cases, the DataGridView will evaluate this property at the row level."

"When the user navigates away from the row, the control commits all row changes. The user can also press CTRL+ENTER to commit row changes without leaving the row. To commit row changes programmatically, call the form's Validate method. If your data source is a BindingSource, you can also call BindingSource.EndEdit."

If the view is not updatable, and you want to update the underlying tables, you should probably just query the underlying tables. Then when the data is modified, the data in the underlying tables will be modified.

cgeier 187 Junior Poster

This looks like it would be best in a database. There are free ones like SQLExpress and mySql

cgeier 187 Junior Poster

Try adding the following: this.webBrowser1.ScriptErrorsSuppressed = true;

cgeier 187 Junior Poster

I'm not an expert with regex, but have used it. I think that many of the regex engines use similar syntax although there are some small differences. What worked for me was to start with a small regex expression, test it and then keep adding to it until it did everything I needed. I don't know anything about groovy, but I think that the regular java regex may work.

Rather than starting with:

static propertyPattern = ~/@property\s([\w, =]+)\s(\w+)\s(*?)\w/

Start with

static propertyPattern = ~/@property\s([\w, =]+)/

or less if that is not returning any results.

Here is some basic stuff:
The regular expression is surrounded by forward slashes:

~/ your_regular_expression_goes_here /

\s matches a space, a tab, a line break, or a form feed

\w matches word character [A-Za-z0-9_]

? at end matches zero or one of the preceeding element

* at end matches zero or more of the preceeding element

+ at end matches one or more of the preceeding element

$ at end, matches the end of the string

[] : anything inside bracket are "or"...if it matches anything inside the bracket, it matches.

*? matches like *, however match is smallest possible match

(x) matches "x" and remembers the match (capturing)

(?:x) matches "x" but does not remember the match (non-capturing)

x|y matches either x or y

Also check out regex flags (such as multi-line)

Here are some resources:

cgeier 187 Junior Poster

Click Here to see a post I made using a datagridview. My second post from the end uses a datagridview. It will help get you started. It also shows how to pass data from one form to another (when used with the other classes I posted there).

cgeier 187 Junior Poster

I'm not an expert in this, but have you checked "Local Security Policy?

  • Control Panel
  • Administrative Tools
  • Local Security Policy
  • Security Settings
  • Local Policies
  • Security Options (and perhaps "User Rights Assignment")

Check the event logs:

  • Control Panel
  • Administrative Tools
  • Event Viewer
  • Applications and Services Log
  • Microsoft
  • Windows
  • NTLM
  • Operational

and

  • Control Panel
  • Administrative Tools
  • Event Viewer
  • Windows Logs
  • Security

Can you be more specific as to what you are clicking on?

cgeier 187 Junior Poster

I think that "compare them outputing the words from word1 which are also in word2 and outputing them and viceversa" is not what the assignment asks for. According to the syllabus, the assignment is to "display the letters from the first word which are also in the second word as well as the number" and "display the letters from the second word which are also in the first word as well as the number".

Here is code that gives the output as in the syllabus:

space:

    string space(int numSpaces)
    {
        string mySpace;

        for (int i=0; i < numSpaces; i++)
        {
            mySpace += " ";
        }//for

        return mySpace;
    }//

main:

int main()
{
        string word1, word2;        //declaration of words
        int  count = 0;
        bool letterFound = false;

    // Welcome message 
    cout<< "------------------------------------------------\n"
        << "    Topiloe's Text Analyzer - Release 1.0  \n"
        << "------------------------------------------------\n\n";

    cout << "Enter two words on one line: ";
    cin >> word1 >> word2;
    cout <<"Second word you entered is <" <<word2<< "> \n";
    cout << space(9) << "It is " << word2.length() << " characters long\n";
    cout << space(9) << "Starts with the letter '" << word2.substr(0,1) << "'\n";
    int last_word;
    last_word=word2.length()-1;
    cout << space(9) <<"Ends with the letter '" <<word2.substr(last_word,1) << "'\n\n";

    cout <<"First word you entered is <" << word1 << "> \n";
    cout << space(9) << "It is "<<word1.length() << " characters long\n";
    cout << space(9) << "Starts with the letter '"<< word1.substr(0,1) << "'\n";
    last_word=word1.length()-1;
    cout << space(9) << …
cgeier 187 Junior Poster

As far as formatting goes, create a function call "space"

string space(int numSpaces)
{
    string mySpace;

    for (int i=0; i < numSpaces; i++)
    {
        mySpace += " ";
    }//for

    return mySpace;
}//

To use it: cout << space(9)

Change line 20 (and some of the other ones) to:

cout<< space(9) << "It is "<<word2.length()<<" characters long\n";

In line 38, move most of the output line outside of the for loops (to line 31):

cout<<"The leters in <"<<word1<<"> which are also in <"<<word2<<"> are:" << endl;

Line 38 becomes:

cout << word1[i] << space(1);

Put the following after the for loop (after line 41):

cout << endl;
Ezekiel_1 commented: I have actually used \t to create the tab. I wanted to get the codes right before formatting. thanks +0
cgeier 187 Junior Poster

Does your database use constraints? Do you have a database diagram?

cgeier 187 Junior Poster
  • Click "Start"
  • Select "Control Panel"

If "View by" is "Category":

  • Click "Network and Internet"
  • Click "Network and Sharing Center"
  • Click on "Set up a new connection or network"

If "View by" is "Large icons" or "Small icons":

  • Click "Network and Sharing Center"
  • Click on "Set up a new connection or network"

or

  • Click "Start" and type "vpn" in the "search programs and files" box.
cgeier 187 Junior Poster

Click Here for a resource.

Also Here is another resource.

Here is another.

cgeier 187 Junior Poster

Also, you may Click Here to see about checking if the column allows nulls ("AllowDBNull"). It didn't seem to work for an Access db when I tried it though--AllowDBNull always seemed to be true.

cgeier 187 Junior Poster

If you have the ability to modify the database, you could change "Required" to "false" for the column, or assign a default value.

Alternatively, you could programmatically assign a default value. See below for an example:

*Note: Need using System.Data.OleDb; statement.

private static OleDbConnection dbConn = null;
static string connectStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|Vendors.accdb;";




    public static void InsertAddressBookMainTbl(ref OleDbConnection dbConn, string Country, string State)
    {
        OleDbCommand sqlCmd = null;
        string sqlText = string.Empty;
        string msg = string.Empty;

        try 
        {
            if (dbConn == null)
            {
                dbConn = new OleDbConnection(connectStr);
            } //if 

            if (dbConn.State != System.Data.ConnectionState.Open)
            {
                dbConn.Open();
            } //if 

            sqlCmd = new OleDbCommand();
            sqlText = @"INSERT INTO AddressBookMain(Country, State)
                            VALUES(@Country, @State)";

            sqlCmd.CommandText = sqlText;
            sqlCmd.Connection = dbConn; 

            OleDbParameter paramName0 = new OleDbParameter();
            paramName0.ParameterName = "@Country"; 
            paramName0.OleDbType = OleDbType.VarChar; 
            paramName0.Direction = ParameterDirection.Input; 
            //paramName0.Value = (object)Country ?? DBNull.Value; 

            //if the value is null or empty
            //the value will be "unavailable"
            paramName0.Value = (object)Country ?? "unavailable"; 
            sqlCmd.Parameters.Add(paramName0); 

            OleDbParameter paramName1 = new OleDbParameter();
            paramName1.ParameterName = "@State"; 
            paramName1.OleDbType = OleDbType.VarChar; 
            paramName1.Direction = ParameterDirection.Input; 
            //paramName1.Value = (object)State ?? DBNull.Value; 

            //if the value is null or empty
            //the value will be "unavailable"
            paramName1.Value = (object)State ?? "unavailable"; 
            sqlCmd.Parameters.Add(paramName1); 

            sqlCmd.ExecuteNonQuery();
        } //try
        catch(System.Data.OleDb.OleDbException ex)
        {
            msg = "ERROR: InsertAddressBookMainTbl: " + ex.Message + System.Environment.NewLine + System.Environment.NewLine;
            Console.WriteLine(msg);
            throw ex;
        } //catch
        catch(Exception ex)
        {
            msg = "ERROR: InsertAddressBookMainTbl: " + ex.Message + System.Environment.NewLine + "SQL:" + sqlText + System.Environment.NewLine;
            Console.WriteLine(msg);
            throw ex;
        } //catch
        finally
        {
            if (sqlCmd != null)
            {
                sqlCmd.Dispose();
            } //if
        } //finally
    } //InsertAddressBookMainTbl
GagaCode commented: a great answer i did not use the same function but it really helped me alot to find the answer thank you for the second time +0
cgeier 187 Junior Poster

Line 75, public Prog4() throws FileNotFoundException, delete throws FileNotFoundException, your program already catches this error, and it is not thrown again.

Line 98-103 & 132-137, a user doesn't want to see a stack trace, he/she wants to see a "friendly" error message. A stack trace gives the impression that something has gone terribly wrong. Try something like the following:

        filename = new File("machine.txt");

        try {
                input = new Scanner(filename);
        } catch (FileNotFoundException e) {

            System.out.println();
            System.out.println("Error: File: '" + filename.getAbsolutePath() + "' not found.");
            System.out.println();
            return;

        }//catch

Reading from a file is slow, if possible you only want to read the file once--not over and over again.

Many of your "case" statements are missing the "break;" statement.

Your indentation is inconsistent, and makes your code difficult to follow.

Line 234-236, you use a while statement without braces, only the first statement will be executed. Always use braces, even if not required. It will help to prevent unexpected results. Click Here
to read about some pitfalls in Java.

There may be more things, but this should help.

cgeier 187 Junior Poster

Your code doesn't compile.

In class "Computer":

In (line 52), "compareTo", you state that your return type is "int". However, the return type for "getMmax" is "int []" (an int array). You attempt to subtract two int[] (and return the result).

In class "Prog4":

  • You attempt to create a new instance of "Computer" (line 127) Computer comp=new Computer(0); , but your only constructor in "Computer" accepts int[] (an int array).

  • In line 151, you do the following: comp.setMmax(i); , however "setMmax" accepts "int[]" (an int array) not "int" (an int).

  • In line 161, int a=comp.getMmax(); . "getMmax" returns "int[]" not "int".

cgeier 187 Junior Poster

Are you trying to detect these events on your form? If so, here's an example:

To use the example:

  • Add a MenuStrip named: menuStrip1
  • Add a ToolStripMenuItem named: File
  • Add a ToolStripMenuItem named: Close

  • Add "MouseDown" and "MouseUp" events

        private void closeToolStripMenuItem_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Console.WriteLine("Left mouse down.");
            }//if
        }
    
        private void closeToolStripMenuItem_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Console.WriteLine("Left mouse up.");
            }//if
        }
    
cgeier 187 Junior Poster

I just re-read your question. I'm confused by what you're asking. String "a" isn't defined outside of the class. It is a global variable--which is defined outside of Main. If you are trying to reference it within class "Program" do it as in my previous post.

You could potentially reference it from another class by making it "public static" as stated in a post above. You could also just make it public.

cgeier 187 Junior Poster

Change line 28 to Console.WriteLine(a); or Console.WriteLine(this.a);

cgeier 187 Junior Poster

Delete line 7 which is your package statement.

Try something like the following for your exception (line 133-137):

            catch (NumberFormatException ex) {

                System.out.println("There was an error in the donation box.");


                if (charityDon.contains("$"))
                {
                    javax.swing.JOptionPane.showMessageDialog(null,  "'Charity amount' contains non-numeric characters. Please enter a valid monetary value (do not use '$')." );  
                }
                else
                {
                    javax.swing.JOptionPane.showMessageDialog(null,  "'Charity amount' contains non-numeric characters. Please enter a valid monetary value." );  
                }//else


                return;
            }

I would also change your code to the following:

    private final int WINDOW_HEIGHT = 225;
    private final int WINDOW_WIDTH = 400;

    setSize(WINDOW_WIDTH, WINDOW_HEIGHT);

because when I ran it, the form was larger than needed.

cgeier 187 Junior Poster

You need to create an instance of it with the "new" keyword. SqlDataAdapter da = new SqlDataAdapter(); which should get rid of your error.

Try the following:

String connection = "Data Source=(LocalDB)\\v11.0;AttachDbFilename=C:\\Users...."; SqlConnection conn = new SqlConnection(connection); 
SqlDataAdapter da = new SqlDataAdapter("select * from Tbl", conn); 
ds = new DataSet(); 
da.Fill(ds, "Tbl"); 
dataGridView1.DataSource = ds.Tables["Tbl"];

Click Here
to read more.