Minimalist 96 Posting Pro
Public Class Form1
    Dim myarr() As Char 'create an array to hold the specil characters'
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        TextBox1.Text = "Hi! Hello, How are you?"
        myarr = {"[", "!", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "\", "-", ".", "/", ":", ";", "<", "=", ">", "?", "@", "]", "^", "_", "{", "|", "}", "~", "ยง"}
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Application.Exit()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim n As Integer = Len(myarr)
        Dim i As Integer
        For i = 0 To n - 1
            If TextBox1.Text.Contains(myarr(i)) Then
                Debug.Print(myarr(i))' print character if found
            End If
        Next
    End Sub
End Class
Minimalist 96 Posting Pro

You need to make sure that you do understand the difference between a string and a number.
Label5.Text = 0 should be Label5.Text = "0" . You are mixing this up throughout your code. Switch Option Strict on in the editor,

Minimalist 96 Posting Pro

maybe:
dim box as new mult

Minimalist 96 Posting Pro

So I got a problem with the settings Tab in VB.Net. The settings are not displaying properly. There is a gap in the middle of the display.

set.jpg

The second problem I have is this: VB creates a settings file in the App Data folder: InClass.exe_Url_eoaehkudo2dalqpbmdabua2u0ulhsacj
However, If I try to synchronize settings to get rid of the gap, I get the following msg.

Msg.jpg
Here I can see that synchronize looks into the correct folder but the file names are different. Any ideas hoe to fix this?
Thanks for reading

Minimalist 96 Posting Pro

Maybe using show and hide is abetter way to deal with the issue.

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Form2.Show()
        Me.Hide()
    End Sub
End Class

Public Class Form2
    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.Close()
        Form1.Show()

    End Sub
End Class
SoftBa commented: Thanks man. This is behavior I was looking for. +2
Minimalist 96 Posting Pro

Mybe try to assign a string to lblcs.Text like:
lblcs.Text = cstr(Val(lblcs.Text) + 1)

Paturo.po commented: It doesn't work Sir. +0
Minimalist 96 Posting Pro

well just use a timer:

 Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) Then
            Dim num1 As Double
            Dim num2 As Double
            Dim num3 As Double
            num1 = Convert.ToDouble(TextBox1.Text)
            num2 = Convert.ToDouble(TextBox2.Text)
            num3 = num1 + num2
            TextBox3.Text = CStr(num3)
        End If
Minimalist 96 Posting Pro

Tis is a solution for vb.net

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim num1 As Double
        Dim num2 As Double
        Dim num3 As Double
        num1 = Convert.ToDouble(TextBox1.Text)
        num2 = Convert.ToDouble(TextBox2.Text)
        num3 = num1 + num2
        TextBox3.Text = CStr(num3)
    End Sub
Minimalist 96 Posting Pro

In cases where I need to check my printouts I have installed a virtuel pdf printer and print to this one before committing to paper. I use Cute PDF Writer on these occasions.

Minimalist 96 Posting Pro

So o.k ifyou want to stick with vb6 then you could do the following;

Dim txtlen As Integer ' the length ofwords
Dim lencount As Integer ' the integer to hold the number of words longer then 6
lencount = 0 ' inialise to 0
Dim wordarray() As String' an array to hold all words
Dim rword As Variant ' the words we return fom the array
wordarray = Split(Trim$(RichTextbox1.Text), " ")' use the split function to from the string, in may case I use a rich textbox
For Each rword In wordarray
txtlen = Len(rword)
If txtlen > 6 Then
lencount = lencount + 1 ' found a word >6 increase the counter by 1
End If
Label1 = CStr(lencount) ' put the result into a label to display
Minimalist 96 Posting Pro

You are assigning a double to a string.

Should probably be like:
dim num as double

num=CDbl(txtMonthly.Text) / CDbl(txtdr.Text)

Minimalist 96 Posting Pro

You should check first if the list contains the item you want to add and then decide what to do. You might want to exit the sub after line 37. Also make sure to post in the correct forum. Vb.net?

Minimalist 96 Posting Pro

O.K. I assume that you have added a totalsum row to your database which will give you a field that contains the total. If not then check this out:
https://www.gcflearnfree.org/access2016/how-to-create-calculated-fields-and-totals-rows/1/

To display this one field in your textbox you need a query against your database and display the result. Here is how to do this:
https://www.daniweb.com/programming/software-development/threads/461537/how-to-show-access-database-value-in-textbox

Minimalist 96 Posting Pro

O.K. if came across of being rude I do apologize as this was not the intention.

JamesCherrill commented: Well said +14
Minimalist 96 Posting Pro

O.K than we go back to part of the initial statement:
"You get challenged to a game of coin toss. Both players pick a sequence of coin toss results (heads or tails). The coin is repeatedly tossed until the sequence for one of the players occurs."

Here it states that a coin is reapetedly tossed which means that for each toss a random number must be newly initiated. Since Jim's code doesn't do this means the programming is not refleting the requirement as stated and hence the code is wrong not addressing the requirement.

Maybe the initial statement should have been, " Use my code for the game and follow the instructions and you will always win"

Minimalist 96 Posting Pro

Teme64 was correct in his first explanation of the probabilty, so one mark up. The theory has been proven an can be assumed to be true. What then follows is that any computer program that tries to mimick reality has to come as close as can be to that reality. So if this is not achieved, the programming is faulty or the random number generator is not good enough. In this case I reckon that the program is not good enough because each coin toss is independent of the previous result and also independent of the following result.

Minimalist 96 Posting Pro

First of all set options to strict on and infer to off. You find these by clicken on myproject in solution explorer and the compile option.
To set a variable for the class or module declare these before the Load method like:

Public Class TheName
Dim LastName as string="" or
Dim LN As String = ""
Private Sub TheName_Load
Now the variable will be available throughout your form.

If you need to make a variable gobal throughout your application(more then one form etc) you need to add a module to your apllication.
You do that by going to the menu bar -> Project-> Add Module.
You can then declare a variable ther and make it available to all forms.
Public LN as string=""
Also note the quotes "" to declare an empty string.
This " " will declare a string with a space in it.

Minimalist 96 Posting Pro

Well, the displayindex is indeed the problem as to my original question. The DataGridViewColumnCollection also refers to the indexes as the datagridview was originally created as to my understanding.
At the moment I use this code and it works good. The benefit here is that I don't need to rename the columns as I only swap the relevant cells.

 For ii = 0 To Maintt.DataGridView1.ColumnCount - 1
            If Maintt.DataGridView1.Rows(0).Cells(ii).Value.ToString = myday1 Then
                For intI = 2 To Maintt.DataGridView1.RowCount - 1
                    str = Maintt.DataGridView1.Rows(intI).Cells(ii).Value.ToString & " "
                    str1 = Maintt.DataGridView1.Rows(intI).Cells(ii + mydiff).Value.ToString & " "
                    Maintt.DataGridView1.Rows(intI).Cells(ii).Value = str1
                    Trim(Maintt.DataGridView1.Rows(intI).Cells(ii).Value.ToString)
                    Maintt.DataGridView1.Rows(intI).Cells(ii + mydiff).Value = str
                    Trim(Maintt.DataGridView1.Rows(intI).Cells(ii + mydiff).Value.ToString)
                Next
            End If
        Next

This way there is no problem with the saving.
You loose some you get some. I came accross the displayindex method and thought of it as good idea. Maybe it is just more of an academic question now. Someone might have this brilliant idea?

Minimalist 96 Posting Pro

So here is some more explanation:
This would be the method I would like to use if can figure out how to change the indexes.
This is the code to swap- timetabler can click in any column that displays the first week name then the second. The program will find the first occurance of the first name, than the first occurance of the second name, than work out the distance via these indexes. I than just need to loop through, find the first occurance and swap using the distance.
After the swap completes I rename the days.

Swaps:

        For ijj As Integer = 0 To Maintt.DataGridView1.ColumnCount - 1
            If CStr(Maintt.DataGridView1.Item(ijj, 0).Value) = myday1 Then
                Maintt.DataGridView1.Columns(ijj).DisplayIndex = ijj + mydiff
                Maintt.DataGridView1.Columns(ijj + mydiff).DisplayIndex = ijj
            End If
        Next

Rename:

        For ijj As Integer = 0 To Maintt.DataGridView1.ColumnCount - 1
            If CStr(Maintt.DataGridView1.Item(ijj, 0).Value) = myday1 Then
                Maintt.DataGridView1.Item(ijj, 0).Value = myday2
            ElseIf CStr(Maintt.DataGridView1.Item(ijj, 0).Value) = myday2 Then
                Maintt.DataGridView1.Item(ijj, 0).Value = myday1
            End If
        Next
Minimalist 96 Posting Pro

Thank you or your interest. So there is nothing special in the save method:

 Friend Sub savemytimetable()
        Dim j, i As Integer, str As String
        str = ""
        myfileaction(303) 'delete old timetable first
        For j = 0 To Maintt.DataGridView1.Rows.Count - 1 'was j=2
            For i = 0 To Maintt.DataGridView1.Columns.Count - 1
                str = str & CStr(Maintt.DataGridView1.Item(i, j).Value) & ","
            Next
            mytxt = Trim(str)
            myfileaction(160) 'send mytxt to the fileaction and save timetable

            str = ""
        Next
        Exit Sub

and myfileaction(160) just saves the textfile after being called.

 Case 160 'save maintimetable
                Dim myfile As System.IO.StreamWriter
                myfile = My.Computer.FileSystem.OpenTextFileWriter(mypath & "\" & constfoldername & "\" & timetableselected & "\" & "TimeTable.txt", True)
                myfile.WriteLine(mytxt)
                myfile.Close()

Loading the time table:

 Case 161 'load timetables into form
                If My.Computer.FileSystem.FileExists(mypath & "\" & constfoldername & "\" & timetableselected & "\" & "TimeTable.txt") Then
                    Dim readText() As String = File.ReadAllLines(mypath & "\" & constfoldername & "\" & timetableselected & "\" & "TimeTable.txt")
                    Dim delimiters() As Char = {","c}, parts() As String, iPart As IEnumerator
                    Dim s As String, i, j As Integer
                    j = 0
                    For Each s In readText
                        parts = s.Split(delimiters)
                        iPart = parts.GetEnumerator
                        For i = 0 To Maintt.DataGridView1.Columns.Count - 1
                            Maintt.DataGridView1.Item(i, j).Value = parts(i)
                        Next
                        j = j + 1
                    Next
                End If

So there is nothing special there.

Minimalist 96 Posting Pro

endedit method didn't help. After saving and reloading the data came back as was saved previously.

Minimalist 96 Posting Pro

The datagridview is saved as a plain text file.

Minimalist 96 Posting Pro

Good day guys,
here is another question I have, working with vb.net community 15. I have a large datagridview to display all lessons for my school timetabling program. There could be up to 14 timeslots = lessons per day. Now I like a timetabler to be able swap days like Monay with Wednesday etc. I know how to do it via the indexes of columns (slow). However, I came across the displayindex method of swapping columns very fast . Swapping days with 12 columns is in the blink of an eye. The problem is I canโ€™t work out how to than save the dataviewgrid as it is displayed after the swap. I found a few questions to this regard on the net but no answers and the ways I tried didnโ€™t work. Maybe anyone here came across the problem before?

Minimalist 96 Posting Pro

Thanks guys, will look at any of the suggestions.

Minimalist 96 Posting Pro

Thanks for your thoughts on this and I marked you up a point. I just wonder how large companies are doing this but haven't found anything on the web. I shall keep thinking about it.
Thanks again

Minimalist 96 Posting Pro

Thanks for the reply.
I read the articel in the link. What I don't want is to hard code into the program. So what I think of is this: Customer goes to the website, likes the program, pays and than get redirected to the download site. Here the customer is requested to put the school name in. Possibilty1: I could generate a textfile that is downloaded with the program and at startup the program reads the textfile, moves the name encoded into settings and as plain text into settings again. The text is used to display the school name on print outs and checks against the encoded name that nor manipulation has taken place. That way every customer basically gets a differently activation. But is this possible or is there a better way?

Minimalist 96 Posting Pro

Good day community,
I have completed vb.net program (a school timetabling program) and I am in the process to create a website. At the moment word -press on wamp server and parallel Microsoft Expression Web 4. To sell the program off the website, either clickonce or downloaded, I request the customer to input the school name. The school name is displayed on all printouts and specific to the school. Qustion: How would I get the school name into the programs settings before or while the program is installed so on first startup it displays the school name. ? Is this at all possible?
Thanks for reading this.

Minimalist 96 Posting Pro

@ ddanbe and @ rproffitt
Thanks guys.

Minimalist 96 Posting Pro

You want to try it this way:

dim a, b, res as integer
dim c as string
a=10
b=5
res= a+b
c= res.tostring
 Debug.Print(c)
Minimalist 96 Posting Pro

Well, I am not on a network so I can't test if all instance of excel are going to be closed. However testing on my machine shows that: if you open more than one instance of excel through vb.net of directly starting excell all instances will be killed. To work out how many instance of excel your machine can see just convert the code I posted to:

Dim obj1(1) As Process
        Dim counter As Integer = 0
        obj1 = Process.GetProcessesByName("EXCEL")
        For Each p As Process In obj1
            counter += 1
        Next
        Debug.Print(counter.ToString)
    End Sub

If you don't run an instance of excel the counter should be 0 which means also that either your machine is not running excel and no one else is running excel, hence you can kill all instances of excel. If you however not running excel and the counter >0 you need to find a way to only kill your instances of excel and there the process id comes in. Follow the link I posted.

ddanbe commented: Helpful. +15
Minimalist 96 Posting Pro

The sledgehammer method would be to close all excel processes. This can be done with:

  Dim obj1(1) As Process
            obj1 = Process.GetProcessesByName("EXCEL")
            For Each p As Process In obj1
                    p.Kill()
                Next

However, if others are also using excel , their processes will also be killed.
Reference the this discussion:
http://stackoverflow.com/questions/11761379/excel-process-still-runs-after-closing-in-vb-net

rproffitt commented: Starts up Peter Gabriel's Sledgehammer. Thanks. https://www.youtube.com/watch?v=g93mz_eZ5N4 +11
Minimalist 96 Posting Pro

First thing to remark is your dim of gpa as Integer. It most likely is a decimal.

Minimalist 96 Posting Pro

Its properly much easier to work from the lefthand side of the list. You just roughly know the max length of the first string, give some space and add the second. so if x is the length of the max length string ,say 12, you do space(-x+15) & next string. This will place the second string always at pos 15,regardless of the length of the first string.
`Private Sub Form_Load()
Dim str1 As String
Dim str2 As String
Dim x As Integer
Dim x1 As Integer

str1 = "abc"
str2 = "abcdef"
x = Len(str1)
x1 = Len(str2)
List1.AddItem (str1) & Space(-x + 15) & (str1)
List1.AddItem (str2) & Space(-x1 + 15) & (str2)
End Sub Linup.jpg `

Minimalist 96 Posting Pro

You can check for various types. This comes from stackoverflow:

Private Sub Command1_Click()
 Dim x As Variant
    ''//These are all different types:
    x = "1"
    'x = 1
    'x = 1&
    'x = 1#
    Select Case VarType(x)
        Case vbEmpty
        Case vbNull
        Case vbInteger
        Label1 = "Integer"
        Case vbLong
        Case vbSingle
        Case vbDouble
        Case vbCurrency
        Case vbDate
        Case vbString
        Label1 = "String"
        Case vbObject
        Case vbError
        Case vbBoolean
        Case vbVariant
        Case vbDataObject
        Case vbDecimal
        Case vbByte
        Case vbUserDefinedType
        Case vbArray
        Case Else
    End Select
Minimalist 96 Posting Pro

Did you check the rules for uploading files to the server. Most enforce some rules. Just google: "upload fiels restrictions" and you will find heaps of different entries to different servers.

Minimalist 96 Posting Pro

Thereare a few videos you can follow and see if it gives the required result:
https://www.youtube.com/watch?v=FPBMoibAmU0
https://www.youtube.com/watch?v=vQhjnMxRuGs

Minimalist 96 Posting Pro

You need to show the code where the error happens.

Minimalist 96 Posting Pro

You can only split on a charcter I think. So you need to replace "<br/>" with say "," and then you split the string, like:

Dim s As String = "cat dog <br/> red green <br/> car box <br/> "
        Dim s2 As String = ""
        s2 = s.Replace("<br/>", ",")
        Dim s3() As String
        s3 = s2.Split(","c)
        For Each st As String In s3
            Debug.Print(st)
        Next
Minimalist 96 Posting Pro

There is good code here how this works. I think you need to rethink your saving of the file and how you load it.
https://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.autocompletemode(v=vs.110).aspx

Here is a complete snippets how it works:

Imports System.IO

Public Class Form1
    Dim path As String = "C:\Test\Copiers"
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ' Create the list to use as the custom source and syve to file
        Dim mytext As String = File.ReadAllText(path & "\ test.txt")
        'create the source mytxt is the saved file we split to generate an array of string
        'str() is the array we useas the source
        Dim str() As String = mytext.Split(","c)
        Dim MySource As New AutoCompleteStringCollection()
        MySource.AddRange(str)
        ' Create and initialize the text box.
        With TextBox1
            .AutoCompleteCustomSource = MySource
            .AutoCompleteMode = AutoCompleteMode.SuggestAppend
            .AutoCompleteSource = AutoCompleteSource.CustomSource
        End With
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Application.Exit()
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim mytxt As String = ""
        Dim myfile As System.IO.StreamWriter
        If Directory.Exists(Path) Then
            Debug.Print("That path exists already.")
        Else
            Dim di As DirectoryInfo = Directory.CreateDirectory(Path)
            Debug.Print("The directory was created successfully")
        End If
        mytxt = TextBox2.Text & "," & TextBox3.Text & "," & TextBox4.Text
        Debug.Print(mytxt)
        myfile = My.Computer.FileSystem.OpenTextFileWriter(Path & "\ test.txt", True)
        myfile.WriteLine(mytxt)
        myfile.Close()
    End Sub
End Class
Minimalist 96 Posting Pro

O.K instead of textboxes you declare some strings. Instead of a listbox(see your line 20 in the original post) you use a list(T) of string and proceed(and I use my post but Jim's is doing the same) but hold the original string in memory. Now you get your field from the database and see if that string from the database is contained in the original string. If it is you loop through your list and upgrade the record, if it is not you loop through the list and add the record to the database.

Minimalist 96 Posting Pro

Here I have used only your string in a textbox to sort your conditions out. Also notice that string.trim only trims one character.
So I successivly remove the parts you don'want and at the end move it into a listbox. You can than use the items in the listbox as your variables via selected item.

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        TextBox1.Text = "D1*X584635*test.one*12643820000000000?*D2*65496321476=2416317950000000000*(Y@12345)*Date:*05*April*2016*Time:*17*01*32 #"
    End Sub
    Private Sub Work(sender As Object, e As EventArgs) Handles Button1.Click
        Dim modifiedString As String = Replace(TextBox1.Text, "D1", "")
        TextBox1.Text = modifiedString
        modifiedString = Replace(TextBox1.Text, "D2", "")
        TextBox1.Text = modifiedString
        TextBox2.Text = TextBox1.Text.Trim({"#"c})
        TextBox2.Text = TextBox2.Text.Replace("**", "*")
        If TextBox2.Text <> String.Empty Then
            TextBox2.Text = TextBox2.Text.Remove(0, 1)
        End If
        Dim parts() As String = TextBox2.Text.Split("*"c)
        For Each item As String In parts
            ListBox1.Items.Add(item)
        Next
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Application.Exit()
    End Sub
End Class
Minimalist 96 Posting Pro

You are using your type cast wrongly. Sender is a callback function:
http://stackoverflow.com/questions/11713250/vb-net-what-is-sender-used-for
Leave this out and you may use:

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        If TextBox1.Text.Contains("Aan De") = True Then
            Dim wordString As String = TextBox1.Text
            TextBox1.Text = Replace(wordString, "Aan De", "aan de")
        ElseIf TextBox1.Text.Contains("Aan De") = False Then
            TextBox1.Text = StrConv(TextBox1.Text, VbStrConv.ProperCase)
        End If
    End Sub
Minimalist 96 Posting Pro

Just assuming that you use datgridview to display data and also just assuning you mean cells in the datagridview have a look at:
http://stackoverflow.com/questions/25302701/change-a-cell-into-a-button-in-datagridview
If this is what you want follow also the references there.

Minimalist 96 Posting Pro

Well there are different ways of printing certain columns of a dataviewgrid, I think this is what you mean? Here are two links:
http://stackoverflow.com/questions/24058180/how-to-print-selected-column-in-datagridview-in-vb-net
http://www.codeproject.com/Articles/16670/DataGridView-Printing-by-Selecting-Columns-and-Row
the second one displays c# code but can be downloaded for vb.net.
I did it a bit differently because I need to manipulate the columns I want to print. I make columns I don't want to print visible= false and copy the visible ones to a new datagridview. Here I manipulate and than print these out.

Minimalist 96 Posting Pro

Well running a webbrouser in a virtual machine is as good a protection as you can get as nothing can change the settings or install. I am trying now sandboxie which seems to be working the same way but not changing the visual dektop in windows 7. Anyway thanks for reponding.

Minimalist 96 Posting Pro

After reading all the hype about the random ware virus I installed BufferZone Pro 64 bit. Worked o.K the first day but after booting today all my visual styles in windows 7 home premium disappeared ( aero glass etc) to make the opened windows really look poor. After uninstalling, everything went back to normal. Hmm, any ideas as I like the protection of virtualisation?

Minimalist 96 Posting Pro

I hope the person who posted the question 7 years ago has waited all the time to get your answer. Just keep on doing the good work.

Minimalist 96 Posting Pro

I would recommend to study the code found here:
https://code.msdn.microsoft.com/windowsdesktop/ListView-Printer-7a9be0a7/sourcecode?fileId=75223&pathId=1512114835
This works out of the box and some modifications should lead to your required result. I use his other code as a starting point to print a datagridview and it showed me how to print data that is wider and longer than A4 and still produces the required result with a few modifications.

Minimalist 96 Posting Pro

The publishing folder is where you put the setup.exe file. So a folder on the desktop will do. If you did read the links you will have found out that with the express edition you cannot easily determine the folder where your program installs. Another way is to go to the debug folder where you program is putting the files when you run from the development. There you should find a file where under type it says application. Click on this one and when it runs you can move it to the dektop, rename it with an exe extension and than move it where ever you want.

Minimalist 96 Posting Pro

O.K. I just tried this process with one of my small programs. Click once applications don't create an exe file and they install into the user profile directory. However, if you goto start you should find your application there. Right mouse click gives you the option to se the properties. From there you can save the path and copy it into the task scheduler. Here are some links that will explain this in more detail.
http://stackoverflow.com/questions/2358910/how-to-allow-installation-in-a-custom-target-directory-and-suppress-auto-start
http://stackoverflow.com/questions/145400/how-do-i-dictate-the-destination-folder-of-a-clickonce-application
Also be aware using schduler on a network reuires admin rights.