TnTinMN 418 Practically a Master Poster

Is this what you mean?

MsgBox "Found here - Cabinet: " & Range("E" & Rng.Row).Value _
       & " Drawer: " & Range("F" & Rng.Row).Value
TnTinMN 418 Practically a Master Poster

MsgBox "Found here " & Rng

Rng is an object. If you wnat the address use Rng.Address.
But move to be inside your if block just in case that Rng is Nothing.

TnTinMN 418 Practically a Master Poster

Chris,

I do not know if this is applicable to your situation, but this technique sort of works for RDLC reports.

  • Set the height of the table to zero. It will not let it be exactly zero, but will set it to some small value.
  • Add a rectangle (no border) to the report and place the table in it. Then set the height of the rectangle to zero; again will not be exactly zero, but close.
  • Toggle the table visibility as you have been doing in an expression.

You the following example, I have set it to page break before the rectangle.

layout
p11
p2
second page with table invisible
p2b

TnTinMN 418 Practically a Master Poster

For future reference: SQL Server Data Type Mappings

TnTinMN 418 Practically a Master Poster

Is this above routine something I can put in and test? f so, what controls do I need to add to "form1" to use it? I'm asking this as I'm a "learn by doing" person.

Of course play with it! I didn't code any teeth into it, it does not bite. (Note to self: learn how to code in teeth).

You can use that anywhere you want to to save control text. It does not have any requirements other than using as shown in the example. It would probably be a good idea to put it in it's own code file. Just go to the Project Menu - Add New Class and replace the default class code created.

It really should have more robust error checking and recovery code, but you can always add that later. The good thing about it is you will only have to modify this one class as opposed to modifying replicated logic in multiple forms.

Please close out this thread. It's long enough.

TnTinMN 418 Practically a Master Poster

Sometimes this happens when the solution files get corrupted. Delete the "projectname.snl" and "projectname.sou" files and then using VB open the project definition file "projectname.vbproj".

TnTinMN 418 Practically a Master Poster

Sorry forgot C#,

object doNotSaveChanges = Word.WdSaveOptions.wdDoNotSaveChanges;
object missing =  System.Reflection.Missing.Value;
doc.Close(ref doNotSaveChanges, ref missing, ref missing);
ddanbe commented: top +14
TnTinMN 418 Practically a Master Poster

Pass "false" in the Close method;

wordDoc.Close(false);

TnTinMN 418 Practically a Master Poster

Don,

I had seen your prior post and decided to add some comments to the example that I had previouly provided. For once I refreshed my browser before posting it and seen that you have got it working. Good job!

Since you seen to be having problems with terminology (wat! you no speekee mi lingo!), I am going to post it anyways so that it may help you understand some of the jibberish. :)

Public Class Form1

   ' the following statement creates an instance of the class ControlTextSaver
   ' the constructor for the class (the "New" subroutine) expects a string that
   ' is the path to a file that will store the Text property for the specified controls
   Private controlTextManager As New ControlTextSaver("savedtb.txt")

   ' Form_Load is an event handler that runs after an instance of the form is created.
   ' the default configuration of VB.Net automatically creates the form instance for you.
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

      ' the following for-next loop is an attempt to show you that you could add the controls to the 
      ' text manager in a loop, eventhough I do not agree with this methodology

      For i = 1 To 3 ' I an only using 3 texboxes for this example
         ' assuming that all the textboxes are parented to a panel
         ' the control manager exposes a List(of Controls) property
         ' since the is just like any other List(of type) instance, 
         ' you can add, insert, …
TnTinMN 418 Practically a Master Poster

Don,

I realized that I did not address the questions you raised in the following text.

...it is within a Panel that I'm using because it needs a vertical scroll bar. This suggests that I may need some other code for it to recognize the TextBox within the panel that IS on the form!! What tangled webs I weave!

Controls can parent other controls. You can make a control a child be another by adding it to the target parent control's Controls collection or by setting the Parent property of the child control.

parent.Controls.Add(child)

or

child.Parent = parent

If all the textboxes are parented to the panel, then you could change Me.Controls to Panel1.Controls (replace Panel1 with the true name of the panel) and your logic would function. "Me" is an internal reference to the class in which you are writing code; in this case the form you are defining. The reason you are able to type the name of the textbox reference and it is recognized by the IDE is because you have defined in the class even if you are not aware that you have done so.

When you drag a control to the design, visual studio executes a design routine for that control that generates the statements necessary to instaniate it and set its properties. This code is then written to the form's designer file. You can view this file by going to the solution explorer window and clicking on the …

TnTinMN 418 Practically a Master Poster

Don,

You are beginning to see the issues that I tried to cautioned you about in this post.

http://www.daniweb.com/software-development/vbnet/threads/449051/saving-multiple-strings-to-a-single-.txt-file-in-top-to-bottom-order#post1941747

Consider the time that you have wasted already just to trying and save some time typing in names of the controls that you wish to save the text from by using a loop to generate the control's name. Is it really worth it?

The class shown in that post will manage the saving and restoring of the Text property. All you need to do is create an instance of it and tell it which controls to manage and then issue it the commands for saving and loading the text at the proper point in your code.

TnTinMN 418 Practically a Master Poster

"A first chance exception of type 'System.NullReferenceException'

Don,

Most likely you have misnamed one of the Textboxes or it is not parented to the form.

Try adding the if-block shown below.

Me.Controls("something") will return either a control named "something" or Nothing (null) if the requested control does not exist in the collection.

Dim txtTmp As TextBox
Using reader As StreamReader = New StreamReader("c:\BusinessBasics\miscspareflds.txt")
    For intIndex As Integer = 1 To 36

        txtTmp = Me.Controls("txbUserFld" & intIndex)
        ' put in this 
        if txtTmp Is Nothing Then 
          msgbox("txtUserFld" & intIndex.ToString() & " not found on " & me.name)
          stop
        end if
        strLine = reader.ReadLine
        txtTmp.Text = strLine

    Next
End Using

If you are running in debug mode, this will stop execution. Do not leave the code in for the final version.

TnTinMN 418 Practically a Master Poster

... "old" BASIC language with Visual Basic. It's clear there is little similarity.

You have made a very important realization with that one. VB.Net is one of several laguages in the .Net family. Each has it's own pro's and con's. VB tends to be a bit verbose for some, but it is for this reason that I like it. I find it much easier to read than say C#.

The important thing to remember is that while a language may offer certain constructs unique to the that language, you will always have access to the base fucntionality defined in .Net.

Converting an object to a string representation is a good example of this. In .Net every object will have a ToString function defined for it even if it has to work its way up the inheritance tree to find the default ToString defined on the Object Class. Pretty much every Type in .Net derives ultimately from the Object Class.

In VB.Net all of these will produce the string "3"

   Dim s As String
   s = "3"
   s = "3".ToString() ' let's be redundant
   s = 3.ToString()
   Dim i As Int32 = 3
   s = CStr(i) ' a VB function
   s = CType(i, String) ' a VB function
   s = New System.ComponentModel.StringConverter().ConvertToString(i) ' a .Net class
   s = Microsoft.VisualBasic.ChrW(51) ' convert the ASCII value to a character

Here are some links regarding data types and type conversion.

Data Type Summary
http://msdn.microsoft.com/en-us/library/vstudio/47zceaw7%28v=vs.90%29.aspx

Type Conversion …

TnTinMN 418 Practically a Master Poster

Don,

What parts do you not understand?

From my perspective the only thing that I see that may be confusing is the save method. In retrospect, I should not have written it that way for someone who at your level of understanding.

The fancy word for the original method that I employed is LINQ (Language Integrated Query). I tend to through these into examples just to see if people are paying attention and ask questions or if they are cut & paste programmers. I tend not to offer future help to that type of person.

Dim output() As String = (From cntrl In savedControl Select CType(cntrl, Control).Text).Cast(Of String)().ToArray()

does the same thing as:

Dim output(0 To savedControl.Count -1) As String 
For i as Int32 = 0 to savedControl.Count -1
    output(i) = savedControl.Item(i).Text
Next i

It is a somewhat of a programming short cut, but can be a pain to debug if done wrong.

If you are having problems with or just need a refresher on the fundumental stuff, this is a good online tutorial.

http://www.homeandlearn.co.uk/net/vbnet.html

The entire jist of the class "ControlTextSaver" is that it is a generic and re-usable block of code for saving and retrieving the text for a list of controls.

All the controls (button, textbox, label) that you use in a WinForm project are derived from a common ancestor class named "Control", hence the word controls. This follows an inheritance pattern. If you look at the documentation for say the …

TnTinMN 418 Practically a Master Poster

Don,

This type of coding is seductive at first glance, but can be a major PITA to maintain.

Say if at some point you decide that you need to use a RichTextBox (or some other control for that matter) for one of the fields so that you can take advantage of it formating capabilities. You are then forced to rewrite all of the save and load logic to accomodate that one simple change.

Additionally, this technique limits you to having all of the textboxes parented to the same control.

You can achieve the much of the perceived reduced coding effort by simply storing a reference to the control in an array or list of controls and then process that list. Granted you will have to load the list, but you can still use the method that Jim has shown you. However, if you ever need to make any changes, you will only need to modify that loading routine and not all of the others.

You may have noted that I purposely used the word "control" above instead of textbox. There is a good reason for this; it is flexibilty. There is no reason to limit yourself to just textboxes. The TextBox.Text property is inherited from the Control class.

Here is a simple example of the technique. I have only put in very limited error checking.

Public Class Form1

   Private controlTextManager As New ControlTextSaver("savedtb.txt")

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      For i = 1 …
TnTinMN 418 Practically a Master Poster

Chris,

When you write "the pages alignment of the tables is off" do you mean the physical positioning on a given page or do you mean that they are not appearing on the Excel tab that you expect?

If it is a physical positioning problem (the table is not at the top of the page) then it may be due to the hidden table having it's PageBreakAtEnd property being set. It may work to change all tables to PageBreakAtStart.

I am assuming that the report you are running is similar to those used in the ReportViewer as the Reportviewrr is based on SSRS. This may not be the case though.

TnTinMN 418 Practically a Master Poster

Don,

When I stated redundant information, I did not mean within a given row.

Since it appears that you want to create some type inventory system, I would assume that you wish to store the supplier information of a given part somewhere. This is an example of what Jim mentioned could be stored in a sub-table and then your record would just store a vendor ID code instead of all vendor info in each record. But this is all a guess at this point.

I find pictures to be a lot easier to understand. Take look at this site for example database layouts.

http://www.databaseanswers.org/data_models/

As far as your current code problem, I see that you are using objCon before you have created an instance of the connection. Thus far you you only defined the variable.

I suggest you place these statements at the top of your code, they will allow the IDE to flag more potential errors for you.

Option Strict On
Option Infer Off

TnTinMN 418 Practically a Master Poster

Oh boy blinky buttons! : )

Give this button a try:

Public Class FlashyButton
   Inherits Button
   Private WithEvents FlashTimer As New Timer

   Private _AlternateBackColor As Color = Color.Green
   Public Property AlternateBackColor() As Color
      Get
         Return _AlternateBackColor
      End Get
      Set(ByVal value As Color)
         _AlternateBackColor = value
      End Set
   End Property 'AlternateBackColor


   Private _FlashDuration As Int32 = 1000
   Public Property FlashDuration() As Int32
      Get
         Return _FlashDuration
      End Get
      Set(ByVal value As Int32)
         _FlashDuration = value
      End Set
   End Property 'FlashDuration

   Private _FlashEnabled As Boolean = True
   Public Property FlashEnabled() As Boolean
      Get
         Return _FlashEnabled
      End Get
      Set(ByVal value As Boolean)
         _FlashEnabled = value
      End Set
   End Property 'FlashEnabled

   Private ElapsedTime As Int32
   Private OrigBackColor As Color
   Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
      If FlashEnabled Then
         Enabled = False
         FlashTimer.Interval = 75
         ElapsedTime = 0
         OrigBackColor = Me.BackColor
         FlashTimer.Start()
      End If
      MyBase.OnClick(e)
   End Sub

   Private AltColorSet As Boolean

   Private Sub FlashTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles FlashTimer.Tick
      ElapsedTime += FlashTimer.Interval
      If ElapsedTime >= FlashDuration Then
         BackColor = OrigBackColor
         FlashTimer.Stop()
         Enabled = True
         Exit Sub
      Else
         If BackColor = OrigBackColor Then
            BackColor = AlternateBackColor
         Else
            BackColor = OrigBackColor
         End If
      End If
   End Sub
End Class

Just add to your project code as a new class and rebuild the project. You should then see it at the top of your toolbox.

TnTinMN 418 Practically a Master Poster

Don,

Do all of those 170 columns define a single record? If so, I suspect based on your past references to excel that you have a lot of redundant data in there. Since you are defining the database, it behooves you to ensure that it is well designed before you start coding any application to interface with it. I suggest that you take a look at these articles.

http://en.wikipedia.org/wiki/Database_design

http://en.wikipedia.org/wiki/Database_normalization

TnTinMN 418 Practically a Master Poster

How come I can not print it?

Please show all your code.

TnTinMN 418 Practically a Master Poster

I have tested this by casting the webbrowser.Document.DomDocument, so hopefully it will work for you.

You used: Dim htmlDocument As mshtml.IHTMLDocument2 = DirectCast(New mshtml.HTMLDocument(), mshtml.IHTMLDocument2)

recast as mshtml.IHTMLDocument3

   Dim doc3 As mshtml.IHTMLDocument3 = DirectCast(htmlDocument, IHTMLDocument3)
   For Each img As mshtml.IHTMLImgElement In doc3.getElementsByTagName("img")
      Debug.WriteLine(img.src)
   Next
TnTinMN 418 Practically a Master Poster

Try recasting the document to a IHTMLDocument3 use getElementsByTagName on the new cast object,

TnTinMN 418 Practically a Master Poster

If it's dynamic code execution, then that can be handled via CodeDom and compile on the fly. Not to difficult to do, but takes some setup to get right.

But based on my understanding of the OP's stated situation, it looks like just some value that needs to be referenced by name.

TnTinMN 418 Practically a Master Poster

after this there existed a variable with the name and value as requested

This sounds like a key-value pair to me. Perhaps a Dictionary will work.

Begginnerdev commented: Dictionaries are a life saver. +0
TnTinMN 418 Practically a Master Poster

You have mixed together various statements that are not necessarily related.

     ConnectionSettings() ' this does what?

     ' I assume that con is a MySqlConnection defined elsewhere
    ' don't need to open connect, the dataadapter will handle open/close
    'con.Open()

    Dim sql As String

    ' you do realize that this dataset will only exist in the context of this code block?
    Dim ds As New DataSet
    Dim da As MySqlDataAdapter

    Dim RowsNo As Integer ' purpose for this ?

    Dim cmd as New MySqlCommand()
    cmd.Connection = con

    sql = "SELECT * FROM tblStudents WHERE StudentID = @studentid"
    cmd.CommandText = sql
    cmd.Parameters.AddWithValue("@studentid", txtStudentID.Text)

    ' why this is here I have no clue
    'cmd.ExecuteNonQuery()

    ' feed the dataadapter the command
    dim da as New MySqlDataAdapter(cmd)

    ' use the adapter to create and fill the table Students
    da.Fill(ds, "Students")

    msgbox(ds("Students").Rows.count.ToString)
TnTinMN 418 Practically a Master Poster

My 2 cents worth on this is if this site actually allowed us to put articles under the tuturial tab that could be referenced a lot of this would be less painful all the way around. I would actually like to see the Tutorial section be a wiki of sorts. I know that would have to have some restrictions put on it in terms of deleteing/editing, but I think that a workable solution could be found where one of the staff could review the submissions before allowing the content to go public.

TnTinMN 418 Practically a Master Poster

Are you trying to tell us that you do not understand how to use the CommonDialog to retrieve the selected file?

If so, take a look at this link: http://www.developerfusion.com/article/11/common-dialog-control/3/

TnTinMN 418 Practically a Master Poster

YouTube users may find this interesting: Legal liability for YouTube viewers

TnTinMN 418 Practically a Master Poster

Most likely your query is failing to retrieve any rows.

strSelect = "SELECT * FROM dbo.hrEmployeeInformation WHERE eiEmployeeID = '" & dhcboEmployeeSelect.Text & "'"

Is "eiEmployeeID" stored as text or is it a number? If it is a number, remove the single quote (') from the the Select statement.

TnTinMN 418 Practically a Master Poster

If you can live with the 28 digit accuracy of the decimal type for the result of the exponentiation, then you can implement your own power function.

    private void test()
    {
        Int32 v = 11;
        Int32 d = 23;
        Int32 n = 187;

        decimal exp = DecPower(v, d);

        decimal m = decimal.Remainder(exp, n);
        string msg = m.ToString();

    }

    private decimal DecPower(decimal Num, Int32 power)
    {
        decimal ret = 1;
        for (Int32 i = 1; i <= power; i++)
        {
            ret = decimal.Multiply(ret, Num);
        }
        return ret;
    }
TnTinMN 418 Practically a Master Poster

I think that the easiest thing for you to do would be design your Panel as a user control, since that sounds like what you are attempting to do anyways. Doing so, will give you the security of working in the IDE.

Go to the Project Menu and select "Add User Control". Design as you want and then execute a Build on the project. After that the user control should show up at the top of your ToolBox under the Tab "Your Applicatiopn Name - Components". Add it to your form like any other control. Just remember that if you need to change its design, first close your form that houses it, then edit the User Control and rebuild before opening the form up.

TnTinMN 418 Practically a Master Poster

Give this a try and see if it is what you expect.

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.BackColor = Color.DarkBlue
        Me.ForeColor = Color.White
        '
        'This creates the Panel

        '*** changed label to panel like you have stated
        Dim pnlOrderEntry As Panel = New Panel
        pnlOrderEntry.Location = New Point(12, 48)
        pnlOrderEntry.Size = New Size(1232, 126)
        pnlOrderEntry.Visible = True
        '*** added this color just so that I could see it, In you don't set a property,
        ' it inherits it from it's Parent control
        pnlOrderEntry.BackColor = Color.Coral
        Me.Controls.Add(pnlOrderEntry)


         '*** add the remaining controls to the panel
        '
        'This creates the label "Part No."
        Dim lblPrtNo As Label = New Label
        lblPrtNo.Name = "lblPrtNo"
        lblPrtNo.Text = "Part Number"
        lblPrtNo.BackColor = Color.DarkBlue
        lblPrtNo.ForeColor = Color.White
        lblPrtNo.Font = New System.Drawing.Font("Sans Serif", 9)
        lblPrtNo.Font = New System.Drawing.Font(lblPrtNo.Font, FontStyle.Regular)
        lblPrtNo.Location = New Point(15, 9)
        lblPrtNo.Size = New Size(77, 15)
        lblPrtNo.Enabled = False
        lblPrtNo.Visible = True
        pnlOrderEntry.Controls.Add(lblPrtNo)
        '
        'This generates the textbox for the user to enter the Part No.
        Dim txbPartNo As TextBox = New TextBox
        txbPartNo.Name = "txbPartNo"
        txbPartNo.Text = ""
        txbPartNo.ForeColor = Color.Black
        txbPartNo.BackColor = Color.White
        txbPartNo.Font = New System.Drawing.Font("Sans Serif", 10)
        txbPartNo.Font = New System.Drawing.Font(txbPartNo.Font, FontStyle.Bold)
        txbPartNo.Location = New Point(15, 26)
        txbPartNo.Size = New Size(263, 22)
        txbPartNo.Cursor = Cursors.Hand
        txbPartNo.AcceptsReturn = True
        txbPartNo.AcceptsTab = True
        txbPartNo.TabIndex = 10
        txbPartNo.Enabled = True
        txbPartNo.Visible = True
        AddHandler txbPartNo.TextChanged, AddressOf txbPartNo_Textchanged
        pnlOrderEntry.Controls.Add(txbPartNo)
    End Sub

    Private Sub txbPartNo_Textchanged(ByVal sender As System.Object, ByVal e As EventArgs)
        Dim txbPartNo …
TnTinMN 418 Practically a Master Poster

Friend just makes them accessible throughout the current assembly (similar to Public, but not accessible outside the defining assembly). If the control does not need to be accessed outside of the control in which it is declared, then Private is fine. Friend is the VB default for autogenerated code; nothing magic about the access level, just what the VB team selected. In C#, the default is private.

The WithEvents statement just allows you to add the "Handles cntrl.Event" to an event handler method for the control. If you do not use WithEvents, you need to use the Addhandler statement to attach a event handler method.

TnTinMN 418 Practically a Master Poster

This is your problem

Private Sub GetWord()
    Dim strWordList() As String = Split(My.Computer.FileSystem.ReadAllText("Words.txt"), vbCr)
    Dim randomGenerator As New Random
    intLine = randomGenerator.Next(0, 64144)
    strWord = strWordList(intLine).ToUpper
End Sub

You are splitting on VbCr. It should be VbCrLf

Or try:

Private Sub GetWord()
    Dim strWordList() As String = IO.File.ReadAllLines("Words.txt")
    Dim randomGenerator As New Random

    intLine = randomGenerator.Next(0, 64144)
    strWord = strWordList(intLine).ToUpper

End Sub

Also, instead of the loop: lblDisplayWord.Text = New String("-"c, strWord.Length)

TnTinMN 418 Practically a Master Poster

Here is another way.

Private Declare Function AssocQueryString Lib "shlwapi.dll" Alias "AssocQueryStringA" _
    (ByVal flags As AssocF, _
     ByVal str As AssocStr, _
     ByVal pszAssoc As String, _
     ByVal pszExtra As String, _
     ByVal pszOut As String, _
     ByRef pcchOut As Long) As Long

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    ByVal hWnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Integer) As Long

Enum AssocF
    Init_NoRemapCLSID = &H1
    Init_ByExeName = &H2
    Open_ByExeName = &H2
    Init_DefaultToStar = &H4
    Init_DefaultToFolder = &H8
    NoUserSettings = &H10
    notruncate = &H20
    Verify = &H40
    RemapRunDll = &H80
    NoFixUps = &H100
    IgnoreBaseClass = &H200
End Enum

Enum AssocStr
    Command = 1
    Executable
    FriendlyDocName
    FriendlyAppName
    NoOpen
    ShellNewValue
    DDECommand
    DDEIfExec
    DDEApplication
    DDETopic
    INFOTIP
    QUICKTIP
    TILEINFO
    CONTENTTYPE
    DEFAULTICON
    SHELLEXTENSION
    DROPTARGET
    DELEGATEEXECUTE
    SUPPORTED_URI_PROTOCOLS
    Max
End Enum

Private Const S_OK As Long = &H0
Private Const MAX_PATH As Long = 260
  Public Function GetAsscociatedExe(ByVal doctype As String) As String
    ' Allocate the output buffer

    GetAsscociatedExe = String$(MAX_PATH, " ")
    Dim pcchOut As Long  ' size of output buffer
    pcchOut = MAX_PATH

    ' Get the full pathname to the program in pszOut
    Dim result As Long
    result = AssocQueryString(AssocF.Verify, _
                              AssocStr.Executable, _
                              doctype, _
                              "open", _
                              GetAsscociatedExe, _
                              pcchOut)


    If result <> 0 Then
        GetAsscociatedExe = vbNullString
    Else
        GetAsscociatedExe = Left$(GetAsscociatedExe, pcchOut - 1)
    End If

  End Function


Sub test()

    ' method 1: get associate file
    Dim exten As String …
TnTinMN 418 Practically a Master Poster

I could be wrong, but is'nt "Persist Security Info" a parameter for connecting to SQL Server and not an old Access mdb file?

TnTinMN 418 Practically a Master Poster

PS: i need to save the data of each line in the Db to a single line in the txt file without space between the data.

I don't understand why you do not what a delimiter between the data as it will be nearly impossible to parse later. But you can always change your mind.

Perhaps a more old fashioned approach will be easier for you to understand.

  Dim lines As New List(Of String)
  For Each row As DataRow In dt.Rows
     Dim line As String = String.Empty
     For Each o As Object In row.ItemArray
        line &= o.ToString
     Next
     lines.Add(line)
  Next
  System.IO.File.WriteAllLines("c:\csnet\p.txt", lines.ToArray)
TnTinMN 418 Practically a Master Poster

You have indicated that you have a database. Why not store the info there?
What type of database is it?
Registry based systems are easy to crack. Usually, all it takes is for the user to identify which key your program has added and delete it to reset the counter.

TnTinMN 418 Practically a Master Poster

First off, thankyou for a well written question. These are so rare in this forum.

Second, I have never done what you are doing, but I have read on it, so take my advice with a grain of salt.

Me.WebBrowser1.Document.InvokeScript("addMarker", New String() {"41.850033, -87.6500523"})

I believe that you may need to pass your string in an Object array instead of the string array.

From the documentation: http://msdn.microsoft.com/en-us/library/4b1a88bz.aspx

Private Sub InvokeTestMethod(ByVal Name As String, ByVal Address As String)
    If (Not (WebBrowser1.Document Is Nothing)) Then 
        Dim ObjArr(2) As Object
        ObjArr(0) = CObj(New String(Name))
        ObjArr(1) = CObj(New String(Address))
        WebBrowser1.Document.InvokeScript("test", ObjArr)
    End If 
End Sub
TnTinMN 418 Practically a Master Poster

I believe that the OP's reasoning may be valid if another application is accessing the DB as well. If both tried to grab total access at the same time, there may be a conflict.

Assuming that you made a typo on the forum (missing opening quote) with the connection string, the second version (Mode=Read;) should prevent you from executing insert/update commands. And yes, I have verified that it blocks writing; it throws an invalid update command when executing.

TnTinMN 418 Practically a Master Poster

Yes, of course. Embedding a file just merges a copy of it into the executable. The My.Resources provides it a Byte array. There are also tools that allow you to retreive it is as an IO.Stream.

Edit: Some programs may what to have the proper extension (.wmv, .jpg, etc.) and a temporary filename will have a ".tmp" extension. You can rename a file using System.IO.File.Move("oldpath\filename", "oldpath\newfilename") or you can use the VB helper method My.Computer.FileSystem.RenameFile.

TnTinMN 418 Practically a Master Poster

I'm sorry, but I do not understand what you are trying to ask.

TnTinMN 418 Practically a Master Poster

Ok. You now got it as an embedded resource, so for the player to play the movie, you will first have to write it to the disk. I like using temporary files for this.

Public Class Form1

    Dim tempfile As String = System.IO.Path.GetTempFileName

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Dim strmTemp As IO.Stream = IO.File.Create(tempfile, 1024, IO.FileOptions.None)
       strmTemp.Write(My.Resources.back_blue, 0, My.Resources.back_blue.Length)
       strmTemp.Close()
       AxShockwaveFlash1.Movie = tempfile
    End Sub

    Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
       ' delete the temp file
       System.IO.File.Delete(tempfile)
    End Sub

End Class
TnTinMN 418 Practically a Master Poster

First off, .Net will be slower than a natively compiled VB6 app.

One thing to check for is late binding of objects. This will really slow things down. If you have not already done so, add the following to the top of your code and then the fun begins; work through all of the IDE error and warning messages.

Option Strict On

not necessary but I also recommend:
Option Explicit On - Inferred by using Option Strict
Option Infer Off

References:

Early and Late Binding

Option Explicit and Option Strict in Visual Basic .NET and in Visual Basic

TnTinMN 418 Practically a Master Poster
TnTinMN 418 Practically a Master Poster

What you want to do is turn off the power supply switch via a software command. I have never seen this type of functionality and do not believe it exists at least not in any published standard.

From the ACPI Specification: http://acpi.info/DOWNLOADS/ACPIspec40a.pdf

A.2.2 Display Power Management

Refer to the Display Power Management Signaling Specification (DPMS), available from:

Video Electronics Standards Association (VESA)
2150 North First Street
Suite 440
San Jose, CA 95131-2029

A DPMS-compliant video controller and DPMS-compliant monitor use the horizontal and vertical sync signals to control the power mode of the monitor. There are 4 modes of operation: normal, standby, suspend and off. DPMS-compliant video controllers toggle the sync lines on or off to select the power mode.
power11power2

For more entertaining reading: http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/DspPMSpc.rtf

TnTinMN 418 Practically a Master Poster

The only thing that could through a nul exception in that statement is "app".

Make sure that app has a value. Add a "Stop" statement likes this, and then inspect app.

      ' start Excel
      app = CType(GetObject("", "Excel.Application"), Microsoft.Office.Interop.Excel.Application)

      Stop

Another option is to modify the app declaration to be like this (add "New" to it):

Private app As New xl.Application ' need this common

and then delete:

      ' start Excel
      app = CType(GetObject("", "Excel.Application"), Microsoft.Office.Interop.Excel.Application)

This will lock you into the particular version of Excel that you imported though.

TnTinMN 418 Practically a Master Poster

That is a shorthand notation that VB allows you to do. In my Import statement I defined xl to be equal to the full declaration.

Imports xl = Microsoft.Office.Interop.Excel

The Ctype is required in my code because I program with

Option Strict On     'no implicit narrowing conversions
Option Explicit On   'all variable must be defined in a Dim statement
Option Infer Off     ' no type inference,  no Dim fred without an "As Something"

and the wb.Worksheets("Sheet1") returns a Worksheet boxed in an Object. A direct assignment would involve an implict narrowing conversion to Excel.Worksheet. Option Strict disallows implicit narrowing conversions.

I prefer to have everything explicit in regards to type definitions.

It's a bit extra typing, but the payback is less chance errors by using the wrong type. The IDE flags its, I take a second to think about what I really meant and 90% of the time I can select a correction from those offered by the IDE; so it eliminates some of the extra typing with two mouse clicks.

Some will also disagree with my choice of Option Infer Off, but to me infer = compiler make a guess about what I mean. Guessing my intent is something that makes me ill when it comes to my code.

Its bad enough that I occasionally type in absolute garbage that is perfectly valid as far as the compiler is concerned. ;)

TnTinMN 418 Practically a Master Poster

@Jim,

I see that you been over on the MSDN forum and found KevinInstructor's (I think that's his tag) ReleaseObject method that he promotes.

That method can still fail if do not follow the One-Dot rule when delcaring a reference to a ComObject.

This code follows the One-Dot rule.

      ' start Excel
      app = CType(GetObject("", "Excel.Application"), Microsoft.Office.Interop.Excel.Application)

      ' open the workbook
      Dim wb As xl.Workbook = app.Workbooks.Open("D:\My Documents\Spreadsheets\TestRangeInterop.xlsx")

      ' get Sheet1
      Dim worksheet As xl.Worksheet = CType(wb.Worksheets("Sheet1"), Microsoft.Office.Interop.Excel.Worksheet)

This does not.

      ' start Excel
      app = CType(GetObject("", "Excel.Application"), Microsoft.Office.Interop.Excel.Application)

      ' get Sheet1
      Dim worksheet As xl.Worksheet = CType(app.Workbooks.Open("D:\My Documents\Spreadsheets\TestRangeInterop.xlsx").Worksheets("Sheet1"), Microsoft.Office.Interop.Excel.Worksheet)

Both get a reference to the worksheet, but the second one causes a non-referenced ComObject (the workbook) to be created. This unreferenced object is tied to Excel and excel is tied to it. So, if you application, ends this reference can not be disposed of and hangs around keeping Excel open.

If you create a reference to it as in the first code block, you can set that reference to Nothing thereby allowing the Garbage collection mechanism can get rid of it.

At least that is my understanding of it and it works for me.

These types of headaches are why I've become an advocate of the open XML document format and the use of Open XML SDK 2.0 for Microsoft Office.

TnTinMN 418 Practically a Master Poster

Iterating through a column as shown above will find the first empty cell, but not necessarily the last used cell in the column. If your user happens to leave one of the textboxes empty, you risk overwritting previous stored information. This could be handled by making sure each textbox is not empty but what happpens if someone edits the spreadsheet and accidently clears a cell?

A technique like shown below will find the last used cell in a column.

Imports xl = Microsoft.Office.Interop.Excel

Public Class Form1

   Private app As xl.Application ' need this common
   Private Const MaxRows As Int32 = 1048576 ' Max rows in Excel 2007 - adjust for your version

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

      ' start Excel
      app = CType(GetObject("", "Excel.Application"), Microsoft.Office.Interop.Excel.Application)

      ' open the workbook
      Dim wb As xl.Workbook = app.Workbooks.Open("D:\My Documents\Spreadsheets\TestRangeInterop.xlsx")

      ' get Sheet1
      Dim worksheet As xl.Worksheet = CType(wb.Worksheets("Sheet1"), Microsoft.Office.Interop.Excel.Worksheet)

      ' get the last used cell in column A

      Dim LastCell As xl.Range = LastUsedCellInColumn(worksheet, "A")

      Dim NextEmptyCell As xl.Range

      Try
         If LastCell Is Nothing Then
            ' nothing used in column A
            NextEmptyCell = worksheet.Range("A1")
         Else

            If LastCell.Row = MaxRows Then
               Throw New Exception("Column is full")
            End If
            ' move down one row
            NextEmptyCell = LastCell.Offset(RowOffset:=1, ColumnOffset:=0)
         End If

         LastCell = Nothing

         ' do what you need to do with the cell address

         MsgBox(NextEmptyCell.Address)


      Catch ex As Exception

         MsgBox(ex.Message)

      Finally

         ' clean up

         NextEmptyCell = Nothing
         worksheet = Nothing
         wb.Close()
         wb = Nothing
         app.Quit()
         app = …