VB6 stores incrementing number in Format property of DTpicker - vb6

In Visual Basic 6, for a legacy project I have to maintain, there is a Form with a DTPicker on it. In the IDE, Format is set to 1 - dtpShortDate. However, viewing the .frm file with a text editor the line is:
Format = 273088513
In hex this is 0x10470001 where 0001 part is encoding the 1 - dtpShortDate.
If I wait a few minutes, save the file again, then the line is now:
Format = 274726915
i.e. 0x10490001. Repeating this procedure produces 0x10590001, 0x107B0001, etc.
This is really annoying for source control as this value is recalculated most of the times that the form file is saved , so source control is polluted with a bunch of useless changes.
My questions are:
What is this value and why is it being included?
Is there a way to prevent it doing this, i.e. so I can make some other change to a form with a DTPicker without generating a useless change for source control?

Related

Determine if Text file is empty or is displaying incorrect information

I saved a .txt file in 2017 with some names and numbers however when I have gone back to open the file now, the file only contains empty spaces - the file has not been modified since the creation date so I am wondering whether I can do anything to retrieve whatever data may be hidden within it. As much as I would like to know what could have happened, I am more interested in retrieving the data itself.

How to prevent specific line/s inside a notepad file from being edited?

I have a file that can be opened thru notepad application.
Basically, this file(which can be opened thru notepad) is created by a software and that software uses the values inside that file to run. You can edit the values inside the file using its software.
I just want specific lines(values) to be restricted from being edited because I am implementing strict values inside that file that no one will be able to edit except me.
Is there any clever way to restrict specific lines inside that file from being edited?
I tried the basic way - I used the change permission read/write on that file but I can't change ANY values inside the file which is undesirable.
Note: I have very little to no experience about python, c++, or java but any suggestion will give me idea to learn from it.
Edit:
Here's an example inside the file:
[Type Data]
Comment=Standard Dispense
[Shared_A]
802=1
807=750
11=0
12=0
.
What I want is restrict the value from row/column "807" which is equal to number 750.
I want this number 750 not to be edited even from the software so that other people will not mess it up. I want to set this value as standard value.
Is there any program that you can write inside that file so that it cannot be edited from the software unless I open that file and edit it?
I work from a production/manufacturing company that uses the software that is used for dispensing.
A text file is simply a sequence of bytes that represent code units to encode code points in any given character set. Every byte value is a potentially legal character encoding, leaving no values to encode additional semantics (like guard regions).
With that it should be obvious that there is nothing you can do to partially limit editing of a file using a standard text editor. Whatever problem you are trying to solve, this is not a solution. Next time around you might want to ask about the problem you are trying to solve rather than your proposed solution.

Save special characters to a CSV that can be opened both on PC(Excel) and Mac(Numbers)

I have a script (that I run on a Mac) that writes degree C (unit for temperature in celsius) to a CSV file. I want this file to be viewed in Excel and Numbers. The problem is that it opens fine on Numbers, but shows weird characters on Excel(Windows, I haven't tested Excel on Mac).
I tried both ℃ (the unicode character) and °C (a degree character followed by a C). On Excel I get this:
I'm pretty sure the csv file is UTF-8 encoded, so I don't know what causes the issue.
Here's something else I noticed, if I save as .txt instead of .csv and open it in excel, then an import wizard shows up. If I just leave anything as default and choose 'Finish' then the symbol does show up correctly. But it's not ideal because my users won't be able to double click on the file to open it.
What is the best way to have the special character display in both programs using the same file?
An answer in this post resolved my issue.
Is it possible to force Excel recognize UTF-8 CSV files automatically?
I have to add \uFEFF to the very beginning of my CSV file.

Replacing recorded values with Data file - Data driven testing

I have recorded a simple Coded UI test from visual Studio 2013. What it does is;
Launches a website
Fills in a form with (8 fields)
Saves the form and closes it
Now, I wish to use a data.csv file to replace those 8 values. All the searching I did, I could only find options where every input field had different method hence was easy to find and replace values. In my case, 1 method and 8 fields.
How do I do that? Where do I make the changes since my main file looks like this:
Where and what changes should I make to use CSV file instead of manual values that I recorded.
My designer file code is as below for couple of input fields:
// Type '123456789' in 'i' text box
uIIEdit.Text = this.createKundeParams.UIIEditText;
// Type '{Tab}' in 'i' text box
Keyboard.SendKeys(uIIEdit, this.createKundeParams.UIIEditSendKeys, ModifierKeys.None);
// Type 'Jeff Hardy' in 'name_i' text box
uIName_iEdit.Text = this.createKundeParams.UIName_iEditText;
// Type '{Tab}' in 'name_i' text box
Keyboard.SendKeys(uIName_iEdit, this.createKundeParams.UIName_iEditSendKeys, ModifierKeys.None);
you can put all the 8 values in 1 csv row and treat them as one input to be passed to the method that sets the fields, alternatively you can change the method to accept one value and field name and sets the field with the value
Create the CSV file.
Add the CSV file to the project.
Make sure the CSV file is deployed.
Add the CSV file as a data source for an individual test.
Read the CSV fields and use them in the test.
The detailed steps, with some variations, are explained below.
Visual Studio 2010 has a "data source wizard" that does some of these steps. Visual Studio versions 2012 and 2013 do not have the wizard and so all the steps have to be done manually.
Create the CSV file
One way is to create the file in a spreadsheet then save it as Comma Separated Values. Another way is to use a text editor and just write the file. I use a spreadsheet program for big data source files and a text editor for creating small files. Some editors add a byte order mark (BOM) at the start of a file, that will be added to the first field name of the CSV which appears to make the field unreadable. See this page for more about the BOM.
Add the CSV file to the project
Use the context menu in solution explorer, select Add -> Existing Item. Then browse to the required file. Note the file filter will probably need to be altered to be . or *.csv.
Make sure the CSV file is deployed
Open the properties panel for the CSV file from solution explorer. Set "Copy to output directory" to "Copy if newer" or to "Copy always". Some documents recommend "Copy if newer" but I prefer "Copy always" as occasionally a file was not copied as I expected. The difference between the two copy methods is a little disk space and a little time, but disks are normally big and the time to copy is normally small. Any savings are, in my opinion, far outweighed by being sure that the file will be copied correctly.
Add the CSV file as a data source for an individual test
Replace the [TestMethod] attribute with the correct data source line. This Microsoft blog shows the replacement code for several possible data source file types. For CSV use:
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV",
"|DataDirectory|\\data.csv", "data#csv",
DataAccessMethod.Sequential), DeploymentItem("data.csv"),
TestMethod]
Note that the file name occurs three times and one copy has a # rather than a .. I have not found any useful documentation about the different fields of the Datasource(...) attribute so cannot advise further on how to choose values for non-CSV data sources.
The |DataDirectory| part above is replaced by the directory where files are deployed when the tests run. The whole file name within the string quotes could be replaced by a full path name of a file, if required.
Read the CSV fields and use them in the test
The Coded UI record and generate tool creates classes with fields that hold values entered into text boxes or used in assertions. Each action method has a ...Params class and each assert method has an ...ExpectedValues class, where the ... is the method name. The default values of these fields are the values used when the test was recorded. The recorded values can be overwritten by an assignment before the action or assertion method is called. The fields of the current row of the data source are accessed from TestContext.DataRow[...].
Suppose a Coded UI test has an EnterValue method that writes text into two fields of the screen and it also has a CheckResult method that asserts one field. The test method might then be written as follows.
[DataSource...
TestMethod]
public void CodedUITestMethod1()
{
this.UIMap.EnterValueParams.UIItem0TextSendKeys = TestContext.DataRow["ValueOne"].ToString();
this.UIMap.EnterValueParams.UIItem1TextSendKeys = TestContext.DataRow["ValueTwo"].ToString();
this.UIMap.EnterValue();
this.UIMap.CheckResultExpectedValues.UIItem0TextDisplayText = TestContext.DataRow["Result"].ToString();
this.UIMap.CheckResult();
}
The ...Params and ...ExpectedValues classes allow the test to create values when the test runs. For example, if the EnterValue method also wanted to write tomorrow's date into a field we could add the following line before it is called:

visual studio able to save state for multiple indivisual files not in solutions?

Often I use Visual studio to edit standalone files (not in a project). So usually I will have like say 6 files opened (3 html files, 1 css file, 2 js files etc)
And the problem is that whenever i close visual studio, I have to locate and re-open all 7 files again (which is a bother really).
Is there a way for us to like save all 7 files in a state file and simply when i open that state file it will open all the 7 files in whatever order I have last saved them as ?
If you have used Notepad++ you will know what I'm talking about, basically when we close Notepad++ and open it the files that were previously opened stay opened, some sort of functionality like this.
Here's two Visual Studio macro methods that should do exactly what you need.
SaveAll() saves all open files and writes a file named status.txt to C: in which all open files are written separated by semicolon (totally independent of project/solution):
Sub SaveAll()
Dim text As String
Dim i As Integer
For i = 1 To DTE.Documents.Count
text += DTE.Documents.Item(i).FullName + ";"
DTE.Documents.Item(i).Save()
Next i
My.Computer.FileSystem.WriteAllText("C:\status.txt", text, False)
End Sub
Next time, when you want to open those files, you simply call OpenAll(). It reads the status file, splits the semicolon separated text, and opens all files:
Sub OpenAll()
'Open status file
Dim text As String
text = My.Computer.FileSystem.ReadAllText("C:\status.txt")
Dim files As String()
files = text.Split(";")
Dim file As String
For Each file In files
If file.Length > 0 Then DTE.ItemOperations.OpenFile(file)
Next
End Sub
It's easy enough to modify this according to your needs (or even add a file dialogue). Thanks for asking this question, it made me focus on the VS macro IDE again and see how powerful it is.
You could just have a temporary or scratch solution for adding these files to, and when you've finished working on them (after days or weeks or whatever) just remove them. Solution files are probably a bit much for this, but you wouldn't have to do any extra work.
Otherwise look at making the recently opened files list a bit longer so they stay in there for longer.
Or use another editor for this purpose. I use Notepad++ for all my non-solution/non-project related files. If you close it without closing the individual files they remain in the editor next time you open it. It's faster and lighter weight than VS too.

Resources