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

All you need is

Dim sw As New System.IO.StreamWriter("C:\StudentMarks.txt", True)
sw.WriteLine(txtStudentName.Text & "," & lblFinal.Text)
sw.Close()

but you shouldn't be writing to C:\ under Windows 7 or you will run into UAC issues.

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

Go to the Daniweb home page.

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

Try System.IO.StreamReader or add the following line at the top of your code

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

The short answer is that you shouldn't save files to C:. This is the root of the Windows system partition and is thus under UAC. If you really must (and you really shouldn't) then you can

Right-click on **C:**
Select **Properties**
Select *Security** tab
Click **Edit**

in the Permissions for C: window

Select **Users(computer\Users)**
Select **Modify** and **Write** under the **Allow** column
Click **Apply**

UAC will ask for authorization

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

The answer depends on whether you are replacing what's in the file (or even if there is already a file) or adding to an already existing file. The easiest methods involve reading or writing all of the lines at once. For example, to read all lines of a text file into a string array you can do

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

To write them back out just do

System.IO.File.WriteAllLines(filename,stringarray)

If the file doesn't already exist it will be created. To read and process a text file one line at a time you can do

Dim sr As New StreamReader(filename)

Do Until sr.EndOfStream
    Debug.WriteLine(sr.ReadLine)
Loop

sr.Close()

and to write a file you can do

Dim sw As New StreamWriter(filename, True)
sw.WriteLine(string)
sw.WriteLine(string)
sw.Close()

If the second parameter is True then the lines are appended to the file. If False, the lines replace existing data.

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

You should do an explicit conversion to Double by

CDbl(txtAssignment1.Text)

but you had better be sure that the string is a valid numeric or you will get an error.

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

I did, indeed, say hmmmmmm. He gets a snotload of endorsements from new accounts that went inactive after they had served their purpose. Add to that the fact that for quite some time he was obsessed with

  1. becoming a moderator
  2. boosting his stats

I repeat, hmmmmmmm.

<M/> commented: ikr... hmmmmmmmm..... +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

we never had sex ed when I was a kid, yet nobody got pregnant. There were no teen pregnancies in my school, and similarly when I was in university none of the students got pregnant.

Yeah. But you live in Europe, not in the US where they have really warped notions about sex, nudity, etc. From what I know, Europeans aren't so uptight about all that. I don't know how old you are so I can't comment on the era you grew up in, but since I was a teen (1966-1973) kids in North America have gotten more and more sexualized, both because of the media (didn't have suggestive or explicit music videos and nobody heard of twerking) and because the widespread use of hormones has pushed down the age of puberty. I also do not recall anyone in my high school becoming pregnant, but that doesn't mean it did not occur. My university had thousands of students so unless someone in my close circle got knocked up I was unlikely to hear about it.

When the government goes out of its way to deny knowledge and availability of proper contraception then perhaps ignorance is an excuse.

my parents both worked in a factory from their early teens

A lot of the factory jobs in the US have been moved offshore.

they also made it possible for both of us to go to a decent college

The costs of college have skyrocketed to the …

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

Hmmmmmmm.

ddanbe commented: Hmmmmmmmm +0
Mike Askew commented: did someone say hmmmmmmmm? +0
<M/> commented: He said hmmmmmmm... +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Racquetball, squash and badminton but years ago bbk (before bad knees). I never cared for team sports.. I preferred one-on-one.

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

Used to play some piano many years ago.

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

If you can distinguish between whether a textbox is in column 1 or column 2 then you can save yourself a lot of coding. Let's assume that you have the textboxes arranged and named as follows:

TextBox1      TextBox2
TextBox3      TextBox4
.
.
.
TextBox29     TextBox30
txtSumCol1    txtSumCol2

Note that all odd numbered textboxes are in column1 and all even ones in column 2. Note also that the only controls starting with "TextBox" are the controls that you want to add up.

Public Class Form1

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

        'add handler for text changed for all user entry fields

        For Each tbx As TextBox In Me.Controls.OfType(Of TextBox)()
            If tbx.Name.StartsWith("TextBox") Then
                AddHandler tbx.TextChanged, AddressOf TextBox_TextChanged
            End If
        Next

    End Sub

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

        Dim col As Integer = ColNum(sender)
        Dim sum As Integer = 0

        'recalculates the sum of all textboxes that are in the column
        'containing the textbox that was changed.

        For Each tbx As TextBox In Me.Controls.OfType(Of TextBox)()
            If tbx.Name.StartsWith("TextBox") Then
                If ColNum(tbx) = col Then
                    If IsNumeric(tbx.Text) Then sum += CInt(tbx.Text)
                End If
            End If
        Next

        Me.Controls("txtSumCol" & col).Text = sum

    End Sub

    Private Function ColNum(ctrl As Control) As Integer

        'Returns the value 1 or 2 to identify which column the textbox
        'is in. Odd numbered boxes are in column 1 and even numbered
        'boxes are in column 2.

        Return IIf(CInt(ctrl.Name.Substring(7)) Mod 2 = 0, 2, 1)

    End Function

End Class

This code works …

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

I get the point AD is trying to make. I agree that if you can't afford to keep something than you should't try to acquire it. This applies to houses, boats, and, yes, even children. I agree that children can be unplanned but sometimes they are unplanned, not because of carelessness but because of ignorance (when proper sex-ed is not taught) or because of rape (which certain parties have stated would still not qualify you for an abortion). But when the rich decide that you should not be able to afford a house, car, family, because they want an even bigger piece of the pie then there is something seriously wrong.

Here is a short (7 minute) video narrated by Ed Asner that is causing a bit of a stir in some circles. I especially like the discussion of the "look over there" strategy that has been used by several administrations to distract us from the real issues.

so people now live a lot longer than they were supposed to based on the design of the pension system.

Well, that's going to be changing if the Republicans get their way with their attempts to shut down Obamacare and privatice Social Security. And it is expected that the current generation of middle aged women will have a shorter life expectancy than their mothers.

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

Microsoft SQL Management Studio Express can be downloaded from here

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

Yes on average living standards have improved

Living standards have gone down over the last few decades as wages dropped and the middle class had less and less disposable income and more debt.

so many people think redistribution of wealth is akin to communism or satanism

The entire financial system is based on the transfer of wealth. When you work, wealth is transferred from the company to you. When you spend it, it is transferred from you to the shopkeeper. When you are taxed, wealth is transferred from you to the government and, hopefully, into services that benefit society as a whole.

Incidentally, where did the rich get the idea that they create jobs? Jobs are created by people who spend money on goods thereby creating a demand for products which are then made by businesses. If the masses don't have the money to spend on goods then the jobs disappear. If the jobs are all shipped overseas then wages do no go to the masses to spend on goods, etc.

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

Work? What's work? I use whatever is appropriate, except I never use public transportation. I do use my bicycle whenever possible.

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

GET A JOB

That would be a lot easier if the corporations hadn't been shipping all of the manufacturing jobs overseas. And now a lot of the jobs that are left do not pay enough to live on.

average productivity of the USA has been decreased

I believe that studies show that Americans are more productive now than in the past. Unfortunately the benefits from that gain have gone to the corporations (whose profits have increased) instead of the workers (whose net income has been steadily dropping for decades).

Except that the stuff that would prevent you from getting pregnant (or undo it if it happens by accident) is kinda expensive and you want to cut the programs that would help the poor/unemployed pay for it.

Plus the Republicans don't want to teach sex-ed or provide birth control. They just want people to stop having sex. period.

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

You can also download the free SQL management console which greatly eases management tasks like creating databases, setting permissions, etc. Once a database has been created in the GUI you can generate the SQL commands necessary to recreate the database if necessary.

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

I think the question should be why is the government cutting food stamps for poor people but leaving subsidies for wealthy corporations making record profits and run by rich people who only want to end handouts for the poor. Agricultural subsidies were actually increased this year. If the Republicans want the government out of their business then they should comply and immediately end all subsidies and handouts to corporations. Of course, those same rich people could always refuse subsidies on principle. I imagine only Warren Buffet would be willing to entertain that.

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

Just replace Debug.WriteLine... with your own code

Dim lines() As String = System.IO.File.ReadAllLines("d:\temp\test.txt")

For i As Integer = 6 To UBound(lines) - 2
    Debug.WriteLine(lines(i))
Next
Begginnerdev commented: Short and sweet +9
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Nah. Never happened. Like so many things, it's probably better in my memory than it was in real life. Back then it was awesome. I wonder how it would stack up today. Two of the reasons it was so great

  1. It came with ReXX ports
  2. It relied on the blitter for its responsiveness

ReXX is a scripting language that predate Python by at least a decade. A blitter was a dedicated graphics co-processor that was responsible for the Amiga's incredible graphics capabilities.

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

I got my Amiga 1000 in 1985 (I think). I don't recall how many years I used it. I recall though that I was still using it for quite a few years after IBM and Compaq PCs flooded the home market. As far as I know it is still the only personal computer capable of displaying two different resolutions simultaneously. I eventually made the shift to be compatible with the work environment. But since this is a thread about Sublime I won't wax nostalgic about what could have been ;-P

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

I've noticed that in Windows 7 when you go to restore from a system checkpoint that few checkpoints are shown, however, there is usually a link that says "show more restore points". Perhaps Vista is the same. Personally, I'd rather be presented with the entire list right up front.

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

Before I retired from Manitoba Hydro, all of the programmers that were hired after around 1980 had either a Computer Science or (CS) Computer Engineering (CE) degree. Before 1980 there were a few community college graduates hired. Almost all of the network people came up through the ranks of electrical technician so they had a solid hardware background.

When I compared the CS code with CE code I generally found that CE code was almost never written with consideration for the maintenance people. CE code was more geared toward maintainability but that was because the Engineers were never expected to maintain their own code.

In any case, if anyone ever tells you that a programmer's job is to write code, they are lying. A programmer's job is to provide solutions, preferably with as few lines of clear code as possible.

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

Show us what you have so far. We don't know what kind of database you are using or how you want to connect. Are you using ADO, OleDB, SqlClient?

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

Too bad those aren't for the PC.

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

I had that happen a half hour after a final exam started. I ran into my professor who wanted to know why I wasn't writing it. Major panic attack. I managed to get there before they locked me out.

nitin1 commented: lol :D +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I've gotten too used to TextPad but if I could ever find CygnusEd (editor from my Amiga days) I'd switch in a heartbeat.

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

We can't tell you where to get drivers if you don't tell us what kind of laptop you have. This may not be necessary, however, because most laptops come with a recovery partition which will allow you to restore the laptop to the state it was in when you bought it. This will likely wipe any user files (videos, text, mp3, etc) that you loaded up so if you go the recovery route you should make a backup of your files to an external drive first.

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

This will be of no help to you at the moment, but perhaps it will down the road. I would suggest doing a fresh install of Windows in a dedicated partition (I split 60 gig for windows and the rest for files). Install and configure all of your usual applicatiions, anti virus, etc. Install all Windows updates. Then run the following command in a DOS shell opened as Administrator

DISM /online /Cleanup-Image /SpSuperseded

This could take up to a half hour to run so don't freak. What this does is remove all Windows UNDO files that were created when the service pack updates were installed. It will free up a considerable amount of disk space. Once it completes, run ccleaner to remove all temporary files.

Now download and install the free version of Macrium Reflect. This is a disk imaging program. Use it to create a full image of your Windows partition. Copy this image to an external device if you have one available. If not then just leave the image on your D drive.

Eventually your system will start to misbehave just like it is doing now. When that happens all you have to do is restore the image to C: and apply any updates that were released since you made the image. After you have updated you can make a new image to replace the original.

I've operated this way for years. Restoring an image is always easier than taking a day or more to …

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

What line is throwing the error?

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

Try googling

how to create custom control in vb.net 2010
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It can happen. It might help to have a Linux system on CD (or even better, on a USB stick) to boot from to check the drive. You also might want to invest a few dollars in a product called SpinRite. It is excellent for disk maintenance and data recovery.

Then again, you might just try uncabling the drive and plugging it back in. You just never know.

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

You could always google and include a string that is found on the profile page like

dani last seen site:daniweb.com

The link containing /members/ should be at the top of the results

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

Maybe... depends on who wrote it.

So you determine the validity of an argument based on who presents it rather than on the content of the argument? Doesn't sound very open minded and rational to me.

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

I just wish that people would stop blaming the religion

I blame any system that eschews reason for blind faith in unprovable things. Why shouldn't I blame the religion? As for the "religion of peace" statement, that was discussed at great length here.

But that is kind of getting away from the topic of this thread.

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

What is your level of expertise? Do you know anything about OleDB?

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

You mean Weapons of Mass Disinformation.

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

Bobby Darin? Country? Mr. Splish Splash? I hardly think so. And if you only listened to the first few seconds you should still have heard

Come and sing a simple song of freedom
Sing it like you've never sung before
Let it fill the air
Tell the people everywhere
We, the people here, don't want a war

That does seem to echo the wishes of most Americans.

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

I'd like to see the radio stations in the US, especially in Washington, play this song 24x7

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

If you want to match numeric ranges to strings then please give us the exact mapping and we can help with the code. Your question is very unclear as to what you want.

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

GetFileName returns only the file name portion of folder

For Each folder As String In My.Computer.FileSystem.GetDirectories("D:\")
    ListBox1.Items.Add(System.IO.Path.GetFileName(folder))
Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Your first problem is that you have to use ? for parameters when you use OleDb so your query should be

Dim a As String = "SELECT NAMA, KURSUS FROM DAFTARPELAJAR WHERE NDP = ?"

When I try the code on my database (with the corrected query) it works just fine. If I type a new value in txtNDP and click on txtNama then the control gets updated. Incidentally, what you are doing is not called binding. You are just fetching a value and populating the textbox manually. You might as well just use a datareader.

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

What do you want to happen on the second and subsequent clicks?

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

I had a lot of problems uploading files. It turned out the problem was a Firefox plugin, Ghostery. Try disabling all plugins, then clear your cache and try the upload again. I finally got pissed enough at Firefox that I just switched to Chrome. I haven't had a problem since.

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

I carried a cell phone for ten years before I retired because I was on 24x7 standby. When I retired I turned it in and never got another one. I plan to continue not having one. However, if I did own one I would continue using it as long as it worked rather than contribute to an ever growing pile of electronic gadgets that were abandoned by their owners simply because they had to get the latest and greatest.

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

Are you wanting all of the folders immediately under C or do you mean all of the folders in C:\ and all subfolders? For the first case you can do

ListBox1.Items.AddRange(My.Computer.FileSystem.GetDirectories("C:\").ToArray)

If you want all folders then you can do it recursively by

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

    AddFolders("D:\")

End Sub

Private Sub AddFolders(root As String)

    ListBox1.Items.Add(root)

    Try
        For Each folder As String In My.Computer.FileSystem.GetDirectories(root)
            AddFolders(folder)
        Next
    Catch ex As Exception
        Debug.WriteLine(ex.Message)
    End Try

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

Well, the US supported Batista, Hussein, The Shah of Iran, Marcos, Bin Laden, the Contras to name just a few.

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

The lesson is: "Carry your gun with you all the time!"

Because in a civilized society you just never know when you'll have to kill somoebody.

<M/> commented: ikr... +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It was a win as far as I am concerned but Fox News has to make everything that Obama does look like a failure. Obama was posturing for war and the move by Syria/Russia pulled the rug out from under him so naturally Fox News has to spin that as a humiliating defeat. Remember, these are the same people who criticized Obama for wanting BP to pay for the damages caused in the Gulf because of the the oil rig spill.