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

The Form_Load event is raised when the form is loaded, not when the rendering is completed. That's just the way it is. What are you doing that requires you to wait until the form is rendered?

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

Labels should be used for display only. If you want something clickable you should use a button.

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

If I might offer a suggestion, a typical ini file has the form

[section]
setting=value
setting=value
[section]
setting=value
.
.
.

This form lends itself to a structure that can be easily represented using two nested dictionaries. If you are not familiar with dictionaries, they are objects consisting of key-value pairs. You can think of a dictionary as a type of array but where the index can be of any type and the value is the associated data. In this case, the outer one can be defined as

Dictionary(Of String, <settings>)

where the key is the section name and "?" will be the settings from the ini file from within that section. Because the settings are also key-value pairs, they can also be stored as a dictionary except this dictionary will consist of a pair of strings. So the complete ini file can be stored in the following

Dim inifile As New Dictionary(Of String, Dictionary(Of String, String))

To add an item to a Dictionary you use the Add method. So to add a new section (let's call it "[FolderList]") you use

inifile.Add("FolderList]", New Dictionary(Of String, String))

Let's say there is a setting under this section such as

LastUsed=D:\Temp

To add this setting to inifile you code

inifile("[FolderList]").Add("LastUsed","D:\Temp")

I've written a simple class to do a couple of the operations. The Write method writes only to the debug window, not to the actual file. Note that it encrypts the "value" portion only. The inifile …

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

This whole writing will likely be ignored.

It very well may be ignored. I am sure it will be by many. Please notice my use of the word "suggestions". These are not rules. I do not feel it is my place to try to impose rules. However, it is my opinion that posting a question in a clear and concise manner greatly increases the odds of getting a complete and accurate answer without a lot of needless back and forth for clarification.

If my suggestions are ignored then so be it. At least I tried.

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

To add encryption of the ini file you could try changing the IO code as follows

Public Function INIRead(ByVal INIPath As String, ByVal SectionName As String, _
    ByVal KeyName As String, ByVal DefaultValue As String) As String

    ' primary version of call gets single value given all parameters

    Dim n As Int32
    Dim sData As String

    sData = Space$(1024) ' allocate some room
    n = GetPrivateProfileString(SectionName, KeyName, DefaultValue, sData, sData.Length, INIPath)

    INIRead = IIF(n > 0, Decrypt(sData.Substring(0, n)), "")

End Function

Public Sub INIWrite(ByVal INIPath As String, ByVal SectionName As String, _
    ByVal KeyName As String, ByVal TheValue As String)

    Call WritePrivateProfileString(Encrypt(SectionName), Encrypt(KeyName), Encrypt(TheValue), INIPath)

End Sub

Public Sub INIDelete(ByVal INIPath As String, ByVal SectionName As String, _
    ByVal KeyName As String) ' delete single line from section

    Call WritePrivateProfileString(Encrypt(SectionName), Encrypt(KeyName), Nothing, INIPath)

End Sub

Public Sub INIDelete(ByVal INIPath As String, ByVal SectionName As String)

    Call WritePrivateProfileString(Encrypt(SectionName), Nothing, Nothing, INIPath)

End Sub    

using the Encrypt/Decrypt code you already have. Or you may only want to encrypt the actual values in which case you could see the ini file in a form that would allow you to ensure it is well formatted bur still obfuscate the values. You may have to modify the encrypt/decrypt code to handle the case where a value is "Nothing"

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

Drop a timer on your form. To get the timer to do something every one second, set the Interval property to 1000. To start the timer, set Timer1.Enabled = True. To execute code on every "tick" of the timer, put that code in the Timer1.Tick handler. To stop the timer set the Enabled property to false. You'll want to make sure that the Tick processing is not complex. You want to be done before the next Tick event. Depending on the processing you can have one timer for all fields, or one timer for each field.

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

In case I lose my connection (wireless is spotty at the moment) here is a script you can use to test. Copy and save into query.vbs after modifying as per the comments. Just type the following in a command session from the folder where you saved it:

cscript query.vbs

'------------------------------------------------------------------------------
'
'  Name:
'
'    query.vbs
'
'  Description:
'
'    Query a database table and display all fields in all records returned.
'
'  Notes:
'
'    Modify SERVER, DATABASE and QUERY as appropriate for your system. Depending
'    on your database system (Access, SQL, mySQL, etc) you may have to modify
'    the connection string
'
'  Audit:
'
'    2012-06-29  RevJ  Original code
'
'------------------------------------------------------------------------------

const SERVER   = ".\SQLEXPRESS"
const DATABASE = "mydb"        
const QUERY    = "select * from Attendance"

const adOpenKeySet = 1

'create database access objects

set con = CreateObject("ADODB.Connection")
set rec = CreateObject("ADODB.RecordSet")

'open a connection to the database

con.Open "Driver={SQL Server}"     & _
         ";Server="   & SERVER     & _
         ";Database=" & DATABASE   & _
         ";Trusted_Connection=yes;"

if con.State <> 1 then
    wscript.echo "database could not be opened"
    wscript.Quit
end if

'select and display records from the database table

rec.Open query,con,adOpenKeySet
Dump rec

'close connections

rec.Close
con.Close

'this function displays all records and fields in the given recordset

Function Dump ( rec )

   dim field        'for stepping through field names and values
   dim maxlen       'length of longest field name
   dim name         'field name
   dim value        'field value

   Dump   = 0
   maxlen = 0

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

Keep in mind that in MSSQL, GETDATE() returns a datetime value so the comparison

trans_date >= GETDATE()

will fail if trans_date is not stored as a datetime field or trans_date is in the current day but earlier in the day. To do a proper comparison you would have to take the date part only of GETDATE and compare against that.

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

What database are you using? If you are using SQLEXPRESS you can download SQL Server Management Studio (free) from Microsoft. You can run the query directly against the database without going through VB, data adaptors, etc. See if you get the same results. If using Access, there is a SQL query window available there as well. If you don't have these tools available I can write you a short vbScript to do the query and show the results in a command line window.

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

FORTRAN code is not pretty. Adding extensions like the above sforx is just lipstick on a pig. Some (engineers mostly) argue that FORTRAN compilers product code that is more highly optimized then C. I haven't seen the benchmarks but I imagine that any difference is insignificant compared to the difficulty in working with the language.

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

Let me be clear on one thing. I did not write that abomination. It was written by a company in Pittsburgh. My job was to rewrite it while preserving the logic. The company (which shall remain nameless) that wrote the original code had implemented their own compressison algorithm. I had to rewrite the code while maintaining the interfaces.

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

While going through some old CDs I came across one containing all of the source code for our old ADG/SCADA system (retired 1998). I remembered one horrifyingly bad piece of code that I later rewrote and I thought it might be interesting to post it as an object lesson in how not to write code. I am sure there are worse pieces of code out there in production systems but most are thankfully hidden because the source code is not available (it reminds me about the adage regarding the law and sausages).

The code was written in SFORX (extended FORTRAN which, when run through a preprocessor resulted in standard FORTRAN). All $ keywords are SFORX extensions.

Added 2012-06-29 17:36 - The original code was not written by me

         SUBROUTINE READALL(UNIT,BUFF,*,*,IFIRST)
C*TTL READALL READ FROM ANYTHING
C
C
C
C     THIS SUBROUTINE IS USED FOR READING COMPRESSED OR UNCOMPRESSED
C     DATA INPUT FILES FROM LFC 'UNIT' INTO 80 BYTE ARRAYY BUFF.
C     END RETURNS TO FIRST RETURN, ERROR RTETURNS TO SECOND
C     IFIRST IS LOGICAL WHICH CALLER PROVIDES TRUE ON
C     FIRST READ OFF OF THIS ALLOCATION OF THIS LFC, ELSE FALSE
C*PGMXX READALL  SAVD TOOLS    FS$READA ON 07/23/80 17:43:51 01819B00R01
      LOGICAL IFIRST
         INTEGER*1 BUFF(80)
         INTEGER*4 UNIT
         INTEGER*1 BYTE(120,2)
C
C
         INTEGER*1 IN(2)/2*0/,ISP(2)/2*0/,ITX(2)/2*0/,NB(2)/2*0/
         INTEGER*1 NBT(2)/2*1/
         INTEGER*1 KCR/ZBF/,KLR/Z9F/
         INTEGER*1 EOR/ZFF/
         INTEGER*2 NSEQ(2)/2*0/,ITY(6),ISEQ(60,2),ICKS(60,2)
         INTEGER*4 LFC(2)/2*0/
      INTEGER*4 K,N,IERR,IN0,ISP0,ITX0,NB0,IS,I,ISUM,J
C
C
         EQUIVALENCE (BYTE(3,1),ICKS(1,1)),(BYTE(5,1),ISEQ(1,1))
C
C
      IF(.NOT.IFIRST) GO TO 21
      DO 19 K=1,2
      IN(K) = 0
      ISP(K) = 0
      ITX(K) = 0
      NB(K) = 0 …
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Yay for me.

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

I did not realize that it was as requirement of this site to post fully documented code

It is not a requirement to post fully documented code but my feeling is that because we usually do not know the level of expertise of the OP it is better to add a few comments to make it easier to follow the logic of the code. Please note my use of the word "some".

a simple sort was probably not a good idea as it could easily make a bad situation worse

You are correct to have pointed this out. And let me say again, your efforts are appreciated.

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

Would you please add some comments/documentation as to what this code is doing other than "look for inconsistencies" and "invokes a reordering logic"? Your code is appreciated but it would be even better if the mechanics were explained.

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

What events on form2 are firing before the form is displayed?

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

I have never written a multi-threaded application under Windows (although I have written many on a SEL mainframe running MPX, but that's another animal entirely) but I think multi-threaded is the way to go. You could implement a queue (FIFO or First In First Out) structure where one thread would take data from the serial port and add it to the queue while another would remove data from the queue and plot it. You would not require timers so both threads could operate at full speed.

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

No problem. Glad we were finally able to connect.

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

Try this

Public Class Form1

    Private Sub btnAddNumbers_Click(sender As System.Object, e As System.EventArgs) Handles btnAddNumbers.Click

        If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) Then
            Dim item As New ListViewItem(TextBox1.Text)
            item.SubItems.Add(TextBox2.Text)
            ListView1.Items.Add(item)
        Else
            MsgBox("please enter two numbers")
        End If

    End Sub


    Private Sub btnCalc_Click(sender As System.Object, e As System.EventArgs) Handles btnCalc.Click

        'add one column for the row number,
        '    one column for each row in listview1
        '    one column for the row total

        For i As Integer = 1 To ListView1.Items.Count + 2
            Dim header As New ColumnHeader
            header.Text = "Column" & i
            ListView2.Columns.Add(header)
        Next

        'add some rows to listview2

        For i As Integer = 1 To 10
            ListView2.Items.Add(i)
        Next

        'Do the calculations. One column will be added to ListView2 for each row in ListView1.
        'That column will be (T1 + T2)/row# where T1 and T2 are from columns 1 and 2 in ListView1.
        'The rightmost column will be the sum of all previous columns excluding the first.

        For row2 As Integer = 1 To ListView2.Items.Count

            Dim total As Double = 0.0

            For Each row1 As ListViewItem In ListView1.Items
                Dim val As Double = (CDbl(row1.SubItems(0).Text) + CDbl(row1.SubItems(1).Text)) / CDbl(row2)
                ListView2.Items(row2 - 1).SubItems.Add(val)
                total += val
            Next

            ListView2.Items(row2 - 1).SubItems.Add(total)

        Next

    End Sub

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

I am trying to understand what you want to accomplish here but I think there is a real disconnect between your explanation and the code so let's just scrap the code for now. Forget TextBoxes, ListViews, etc. and just tell me in English what you are trying to do. Pretend that computers do not exist and you are doing it entirely by hand with pencil and paper. What I gather is that you have two numbers which, for the sake of convenience, we'll call T1 and T2 (any resemblance to TextBox1 and TextBox2 is entirely intentional). You also have a table which contains ten rows (but which may contain more or fewer). I don't know how many columns are in this table. The best way, I think, to make your intentions clear is to show me an example of what your table looks like prior to doing any calculations, then show me what it looks like after the calculations are done. Be very clear on what you want because saying "I want the total of the rows" and "I want the total of each row" are entirely different things. If we can get through the explanation without referring to code or computers then I think we can nail this down. For example, I might say:

I have two numbers, T1 and T2, and a table of a variable number of rows. Column one contains a row number and column two contains a dollar amount. I want to calculate column three …

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

I've always been a big fan of letting the computer do as much work as it can. Don't bother writing the bubble sort. The following code uses a sorted dictionary. The key is the line number (with the "N" removed) and the value is the rest of the line. No matter what order you add the lines, when you step through the keys you will always get them in sorted order. That is why I made the key Integer. Not all of your code lines are N####. One is N### (three digits). Note that When I output the lines to the ListBox I ensure that the #### portion is four digits.

Public Class Form1

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

        Dim sd As New SortedDictionary(Of Integer, String)

        For Each line As String In System.IO.File.ReadAllLines("D:\temp\sampleCode.txt")

            Dim linenumb As String      'the N#### portion of the line
            Dim linecode As String      'everything other than N####

            If line.StartsWith("N") Then
                linenumb = Split(line)(0).Substring(1)
                linecode = line.Substring(Len(linenumb) + 1)
                sd.Add(CInt(linenumb), linecode)
            End If

        Next

        For Each linenumb As Integer In sd.Keys
            ListBox1.Items.Add(linenumb.ToString("0000") & sd(linenumb))
        Next

    End Sub

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

This is an excellent, non-technical article on programming that I think every programmer should read at least twice.

gusano79 commented: AMEN +8
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

How are the points being input to the program? Are they coming in on a serial port, file, etc?

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

Instead of using the FileOk event, get the file name, etc by using ShowDialog. This prevents further processing until the file dialog is closed.

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

        If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then

            Dim dbfFileFolder As String = System.IO.Path.GetDirectoryName(OpenFileDialog1.FileName)
            Dim dbfFileName As String = System.IO.Path.GetFileName(OpenFileDialog1.FileName)
            Dim dbfFileNameShort As String = System.IO.Path.GetFileNameWithoutExtension(OpenFileDialog1.FileName)

            If dbfFileName = "GNDITEM.DBF" Then
                frmFileCheck.Show() 'this is my Form2
            End If

        End If

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

If I hadn't have believed it I wouldn't have seen it. - Ashleigh Brilliant

Just to stir things up seemed a great reward in itself. - Sallust

Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind. - unknown

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

In pseudo-code a suggested process is

get a list of all files with the given oldextension

for each oldfilename in the list
    basename = oldfilename stripped of the extension
    compose the newfilename as basename & "." & newextension
    set index = 0
    do while Exists(newfilename)
        increment index
        compose newfilename as basename & " " & index & "." & newextension
    loop
    rename oldfilename to newfilename
next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

There are two ways to run a program created in vb.Net. One is to run it directly from the bin folder somewhere deep in the bowels of your project folder. This is the executable that runs when you run it from inside Visual Studio. The second way is to create an install package which is what you would do if you wanted to distribute the program to other computers that do not have Visual Studio installed. When you create the installer package you identify which components must be distributed in order for the program to run on the target system. Instructions on how to create this package can be found here

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

You can use an encrypted mysql connection. I've never used mysql, only MS SQL and never in an environment that required encryption so I can't walk you through it but if you google "encrypted mysql connection" you might find what you need.

Try here which states

Using encryption

This one activates SSL encryption for all data sent between the client and server. The server needs to have a
certificate installed.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Encryption=true;

and here

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

What error messages are you getting and on what lines?

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

You should check if the entry fields are numeric. Also, you can simplify the if-elseif block as follows

If Not IsNumeric(TextBox1.Text) Then
    MsgBox("please enter a numeric value in textbox1")
    Exit Sub
End If

If Not IsNumeric(TextBox2.Text) Then
    MsgBox("please enter a numeric value in textbox2")
    Exit Sub
End If

.
.
.

If t <= 270.0 Then
    MsgBox("Flight in these conditions is impossible. Please enter the value of Temperature Greater than 270K")
ElseIf mach <= 0.3 Then
    .
    .
    .
ElseIf mach <= 1.0 Then
    .
    .
    .
ElseIf mach <= 5.0 Then
    .
    .
    .
Else
    .
    .
    .
End If

Note that in the first "If" I compare t to 270.0 rather than TextBox1.Text. The way you are doing it compares a numeric value to a string value which will not give you the results you want.

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

Not quite there yet. Column 1 is "the count". The count of what?

The Second and third Column will be a number.
There is a function that i have called Interest rate that just calculates the second and third column data as a percentage.

Apparently all of the columns contain "a number". Are the original numbers in columns 2 and 3 replaced by percentages? What are you calculating the totals of? If column 1 contains a count and columns 2 and 3 contain a percentage then a total of all three makes no sense. What happened to the dates you mentioned in the OP? Please reread my original response about clarity.

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

Can you please be clearer on the format of your listview? For example, you say you have three rows of date. Does that mean the rows after that will have different data? If all rows are the same format then please state the format of the various columns. A clearer statement (as an example) would be:

I have a listview with a variable number of rows. The first column contains a date. The next three columns contain currency amounts. For each row I want to calculate the total currency amounts and place the total in the last column.

If you can be a little clearer then I can probably help you out.

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

It appears the /console switch has been replaced with /admin (in MS Remote Desktop) in Windows 7. I was able to try a test using a virtual machine, however, as I suspected, when you connect remotely, the remote desktop is locked so only the client or remote can be used at one time. As far as I know there is no way to use this merely as a remote viewer. Any attempt to unlock the "viewed" machine terminates the remote connection.

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

I'll check out the LGPL version of QT in September when I get back from the cottage. A 1.7 gig download is a tad large for summer bandwidth. Thanks for the suggestion.

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

You could try setting the Opacity property of the main form to something like 0.5 just before you you display the modal form, then set it back to 1.0 on return.

Me.Opacity = 0.5
form1.ShowDialog()
Me.Opacity = 1.0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Then unless the /console option is still available, the built in remote desktop is likely not an option. Unfortunately I am at the cottage and cannot check it out. I have only the one computer here.

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

My original point was that I think Python is an excellent language that, if I had been aware of it twelve years ago, I would have used instead of vbScript. It would have saved me countless hours of development. I think it is an excellent language for beginners as well as seasoned professionals. My second point was that unless you are willing to pay for something like QT, developing a GUI based app in Python can be daunting. At least that was the case for me.

You seem to feel that VB apps are to be frowned upon. I fail to see why a well written application in any language should be looked down upon. I believe Sturgeon's Law still holds. Ninety percent of everything is crap. That applies equally to VB, C, C++, even Python. Blame the programmer, not the platform.

In any case, we are probably getting off topic.

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

The only GUI development I have done using Python was with either wxPython or Tkinter. I may be mistaken but I believe you have to by QT, whereas Visual Studio Express is free. The first actual GUI app I developed was a Load Advisory Program for our control centre (in C under OS/2). No tools, and all GUI elements had to be coded by hand. It was brutal. In my opinion, the tools you use to develop programs are at least as important as the underlying language. Few would be developing VB.net apps with GUIs without using an environment that removes the grunt work of placing visual elements, or an interactive debugger that supports breakpoints and step-by-step source level debugging.

Nice to see you back. I hope the move went well.

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

@Habitual - sugar gliders. Hmm. Aussie?

Two cats at the moment. In 30 years we've had three Irish Setters, one Shepherd/Husky cross and two cats other than the current ones.

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

I started scripting around the year 2000. I had been a professional programmer for around 25 years. None of my code required a user interface and the ability to inspect/modify code at three in the morning was critical so vbScript filled the bill. It was free and required no special IDE. Had I known about Python at the time I might have used it instead of vbScript. Using Python as implemented today I could have cut my programming time in half and my consumption of antacids by even more.

However, that was because my apps required no GUI. Developing apps in Python requiring a GUI is painful in the extreme. Using wxPython, everything must be done by hand and little of it is intuitive. Developing a GUI in VB.net on the other hand is almost trivial in comparison.

Based on my experience, Python is an outstanding first language and it maintains its appeal even to veteran programmers. But if your goal is to develop any kind of serious GUI, be prepared to invest a lot of time in learning details which you should not have to be concerned about.

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

The following will implement the formula, however, it won't give you the result you want unless you convert the angle from degrees to radians. The following code does that by multiplying the angle by PI/180. I'll assume the formula is correct (trig was never my strong suit).

Imports System.Math

Public Class Form1

    '                       dia           1          dia
    'h   =   sh * s  +  ------------   +  -  *   ------------
    '                   2 * tan(ang)      3      2 * tan(ang1)

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

        Dim sh As Double = CDbl(txtsh.Text)
        Dim s As Double = CDbl(txts.Text)
        Dim dia As Double = CDbl(txtdia.Text)
        Dim ang As Double = CDbl(txtang.Text) * PI / 180.0
        Dim ang1 As Double = CDbl(txtang1.Text) * PI / 180.0

        Dim h As Double

        h = sh * s _
          + dia / (2.0 * Tan(ang)) _
          + dia / (2.0 * Tan(ang1) / 3.0)

        txth.Text = h

    End Sub

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

When I did 24x7 support for our control centre I used Dameware. They had a remote viewer/desktop that could be pushed from the client (me) to the remote desktop on demand. VNC required the prior installation of host software. Of course, both packages require you to have appropriate access rights. I was the sysadmin so I could pretty much do anything. The built in remote desktop (mstsc.exe) might fit the bill but if you have to connect through firewalls there might be config problems. The options for mstsc have changed since Windows XP. There used to be a /console switch that allowed you to connect to the current session. I don't see it in the switches (/?) anymore. Also, it may not be possible to connect to a remote session without blanking the screen of that session. What version of Windows is running on the client and remote machines?

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

Based on your reasoning (avoiding hard coded width), can you please explain why you recommend against

mynum.ToString(StrDup(width,"0"))

which does not have a hard coded width? Is there a reason that

New String("0"c,width)

is preferable to

mynum.ToString(StrDup(width,"0"))
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It's always a good idea to state specifically what you are trying to do. What you have done is say that you are trying to do some math, then shown us uncommented code. Having said that, I would use double rather than decimal.

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

Anyone ever notice in Castle that Beckett wears high heels, but when there is a chase scene her shoes mysteriously change to no-heels?

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

I suspect it is one of those applications that takes highly specialized knowledge. It would be like asking someone with highschool math to solve linear diophantine equations or calculate eigen values.

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

Typically when you want to format an integer with leading zeroes the field width is known beforehand. In that case you can hardcode the width as

mynum.ToString("00000")

which will give you a five digit integer with leading zeroes. More generally you can code

mynum.ToString(StrDup(width,"0"))

where "width" can vary at runtime.

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

How many items do you have in your datagrid and what do you define as "slow"? How long is it taking to complete the loop? Do you get consistent times on successive runs? Do you have anything else running that could be sucking back CPU cycles?

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

If you are using SQLEXPRESS on your PC you can use ".\SQLEXPRESS" for SERVERNAME. For DATABASE you'll plug in the name of the database as used by SQL Server (not the file name).

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

The following code connects to the mydb database on my local copy of SQLEXPRESS.

Dim conn As New SqlClient.SqlConnection
'conn.ConnectionString = "Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;"
conn.ConnectionString = "Data Source=" & SERVER & " ;Initial Catalog=" & DATABASE & ";Integrated Security=SSPI;"

conn.Open()
MsgBox(conn.State)

It uses integrated security (based on your windows logon). If you have to provide a SQL username and password then use the commented out form. A Complete reference for various connection strings can be found here