How do you have "myPics" defined?
Santanu.Das commented: Fine work +4
Ashveen96 commented: i tried it, still same error +0
Ashveen96 commented: i tried it, still same error +0
How do you have "myPics" defined?
After line 126, add the following (for troubleshooting purposes):
string msg = string.Empty;
msg += "x: " + x.ToString() + System.Environment.NewLine;
msg += "y: " + y.ToString() + System.Environment.NewLine;
msg += "SHOT: " + SHOT.ToString() + System.Environment.NewLine;
msg += "GOALIE: " + GOALIE.ToString() + System.Environment.NewLine;
msg += "picPlay Length is " + picPlay.Length + " -- Index numbers are 0 to " + (picPlay.Length - 1) + System.Environment.NewLine;
MessageBox.Show(msg, "Values");
What is the value of "SHOT"? Where is this value set?
Also, line 67 you have for (int i = 0; i < 6; i++)
which should be i < 5
.
If this only happens when using under battery power, it could be a bug in the video driver, the video chip, or a bug in the OS. You may consider opening a case with HP, although there may be a fee involved. You can download the latest Intel video driver from the Intel website. However, if you open a case with HP, they will most likely insist that you download the latest driver from the HP website, which may or may not actually be the latest driver, but rather the last driver that they've tested on that model of computer. As a work-around, you can try changing some of the power settings. See http://windows.microsoft.com/en-us/windows7/products/features/power-management . I don't have access to a computer right now, but look for any settings for video--can't remember, at the moment, if there are any. Can also try changing the processor minimum (on battery) to a higher number. Start with 100% and see if the issue still occurs.
The answer to my question is:
Dim chart1 As New System.Windows.Forms.DataVisualization.Charting.Chart
In order to use it one needs to first be using .NET >= 4. Then a reference needs to be added to System.Windows.Forms.DataVisualization
Add Reference to System.Windows.Forms.DataVisualization:
-Project
-Add Reference
-.NET (tab)
-System.Windows.Forms.DataVisualization
Then add the following "Imports" statement: Imports System.Windows.Forms.DataVisualization
Your issue seems to be on line #29 (line #3 in the original post):Chart1.Series["Series1"].BorderWidth = 3
should be Chart1.Series("Series1").BorderWidth = 3
. VB .NET uses parentheses, not square brackets.
How is "Chart1" defined? What is it's data type?
Here are 3 methods that each accomplish this:
getFolderNameGD (System.IO.Directory.GetDirectories) - version 1:
Public Function getFolderNameGD(ByVal fullyQualifiedFolderName As String, ByVal searchPattern As String)
'return directory that matches searchPattern
For Each fqDirName As String In System.IO.Directory.GetDirectories(fullyQualifiedFolderName, searchPattern, System.IO.SearchOption.TopDirectoryOnly)
Return fqDirName
Next
Return String.Empty
End Function
getFolderNameGDI (System.IO.DirectoryInfo) - version 2:
Public Function getFolderNameGDI(ByVal fullyQualifiedFolderName As String, ByVal searchPattern As String)
Dim di As New System.IO.DirectoryInfo(fullyQualifiedFolderName)
Dim dirInfoArr() As System.IO.DirectoryInfo = di.GetDirectories(searchPattern, System.IO.SearchOption.TopDirectoryOnly)
'return directory that matches searchPattern
For Each d As System.IO.DirectoryInfo In dirInfoArr
Return d.FullName
Next
Return String.Empty
End Function
getFolderNameED (System.IO.EnumerateDirectories) - version 3:
Public Function getFolderNameED(ByVal fullyQualifiedFolderName As String, ByVal propertyNumber As String)
'return directory that starts with
'property number followed by a space and a "-"
For Each fqDirName As String In System.IO.Directory.EnumerateDirectories(fullyQualifiedFolderName)
Dim dirName = fqDirName.Replace(System.IO.Path.GetDirectoryName(fqDirName) & "\", "")
If dirName.Substring(0, dirName.IndexOf("-") - 1) = propertyNumber Then
'Debug.WriteLine("dirName ED: " & dirName)
Return fqDirName
End If
Next
Return String.Empty
End Function
Usage:
'version 1
Dim foldernameGD As String = getFolderNameGD("C:\Temp\Revenue Management\Centralized Revenue Management Service\CRMS Hotels", "1504 -*")
'version 2
Dim foldernameGDI As String = getFolderNameGDI("C:\Temp\Revenue Management\Centralized Revenue Management Service\CRMS Hotels", "1504 -*")
'version 3
Dim foldernameED As String = getFolderNameED("C:\Temp\Revenue Management\Centralized Revenue Management Service\CRMS Hotels", "1504")
example folder name: "1504 - FPbs Meriden"
Public Function getFolderNameGDI(ByVal fullyQualifiedFolderName As String, ByVal propertyNumber As String)
'property number followed by a space and a "-"
Dim searchPattern = propertyNumber & " - " & "*"
'Debug.WriteLine("searchPattern: '" & searchPattern & "'")
Dim di As New System.IO.DirectoryInfo(fullyQualifiedFolderName)
Dim dirInfoArr() As System.IO.DirectoryInfo = di.GetDirectories(searchPattern, System.IO.SearchOption.TopDirectoryOnly)
'return directory that matches searchPattern
For Each d As System.IO.DirectoryInfo In dirInfoArr
'Debug.WriteLine("dirName GD: " & fqDirName)
Return d.FullName
Next
Return String.Empty
End Function
I made some modifications to the code above, made "inputFileEncoding" and "outputFileEncoding" properties instead of parameters, added error handling/logging capabilities, and added more documentation.
Need the following imports:Imports System.IO
Imports System.Text
Add the following to the module:
Public Property InputFileEncoding As Encoding = Encoding.ASCII
Public Property OutputFileEncoding As Encoding = Encoding.ASCII
Public Property LogFilename As String = "RestranLog.txt"
'holds last error message
Private _errMsg As String = String.Empty
'StreamWriter for log file
Private _swLogFile As StreamWriter = Nothing
Private _outputFilename As String = String.Empty
MergeFile:
Private Sub MergeFile(ByVal inputFilename As String, ByVal outputFilename As String, ByVal addFormFeedToFirstPage As Boolean, ByVal removeEndOfReport As Boolean)
Dim fileDataArr() As String = Nothing
Dim logMsg As String = String.Empty
Try
'read input file data into a string array
fileDataArr = File.ReadAllLines(inputFilename, InputFileEncoding)
'add form feed to first page of all files
'except the first one addFormFeedToFirstPage
'should be set to True for all files except
'the first one
If addFormFeedToFirstPage Then
'Chr(12) is ASCII code 0C or 12
fileDataArr(0) = Chr(12) & fileDataArr(0)
End If
'if necessary, remove lines at end of report -
'"End of Report" and some blank lines
If removeEndOfReport Then
'resize array removing last 4 elements (lines)
ReDim Preserve fileDataArr(fileDataArr.Length - 4)
End If
'add Newline (carriage return) to each line
Dim outputDataStr As String = Join(fileDataArr, System.Environment.NewLine)
'append data to output file
File.AppendAllText(outputFilename, outputDataStr, OutputFileEncoding)
'make log file entry
logMsg = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") & " File: " & inputFilename & " merged to: " & …
After reading through some of your posts, I have some suggestions:
Rather than doing this:
Dim propertyNo As String = "1540"
Dim propertyNo1 As String = String.Empty
Dim strLength As Integer = propertyNo.Length
If strLength = 2 Then
propertyNo1 = "000" & propertyNo
End If
If strLength = 3 Then
propertyNo1 = "00" & propertyNo
End If
If strLength = 4 Then
propertyNo1 = "0" & propertyNo
End If
If strLength = 5 Then
propertyNo1 = propertyNo
End If
You can do this:
Dim propertyNo As String = "1540"
Dim propertyNo1 As String = String.Empty
'convert property number to 5 digits
If IsNumeric(propertyNumber) Then
'convert propertyNumber to an integer
'so it can be converted
'to a 5-digit string using "ToString"
propertyNo1 = Convert.ToInt32(propertyNumber).ToString("D5")
End If
Also, the following code should be all that you need to "merge" your files. Unfortunately, there were some things that I was unable to determine, based on the information that you've provided so far--such as the directory name / filename structure. This would be necessary to determine which parts can be automated and which parts require user input. I was also unable to determine if you want the user to be able to decide which files to merge or which properties to merge. Additionally, I was uncertain if a merged file should only contain information for that particular property, or if more than one property can be part of a single (merged) file.
MergeFile:
Private Sub MergeFile(ByVal inputFilename …
It appears that you may be using the wrong encoding when reading and writing the files.
File.ReadAllText Method (String)
...This method attempts to automatically detect the encoding of a file based on the presence of byte order marks...
Byte order mark
...The UTF-8 representation of the BOM is the byte sequence 0xEF, 0xBB, 0xBF...
The following post: What are the differences between Linux and Windows .txt files (Unicode encoding) references some tools that can be used to determine file encoding. I used File for Windows on the original text file you posted (20150228.txt), and it showed "ASCII text". I also used "xxd" (a Cygwin download) which showed the following: 466f757220506f696e747320...
More easily read: 46 6f 75 72 20 50 6f 69 6e 74 73 20...
If you look these (hex codes) up in an ASCII table, you'll see the following:
46=F
6f=o
75=u
72=r
20=space
50=P
6f=o
69=i
6e=n
74=t
73=s
20=space
Note: As you can see, the original file (20150228.txt) doesn't contain a byte order mark.
When I used I used File for Windows on the "converted" (786Restran.txt) file you posted , it showed "UTF-8 Unicode (with BOM) text, with CRLF line terminators". I also used "xxd" (a Cygwin download) which showed the following: efbbbf466f757220506f696e747320...
More easily read: ef bb bf 46 6f 75 72 20 50 6f 69 6e 74 …
Please turn "Option Explicit" on in your VS. It's not a good idea to use variables without declaring them.
In VS 2008/2010:
Click "Tools" in menu bar
Select "Options"
Double-click "Projects and Solutions" to expand it
Click "VB Defaults"
Change "Option Explicit" to "On"
Click "OK"
Also, in looking through your code, it appears that some of your code has gotten out of hand. It isn't apparent what the purpose of "RestranInformationManager.txt" and "RestranFileConversion.txt" are, nor did you include them. It seems that perhaps it is providing information that can be extracted by reading directory contents (ie: folder names and/or filenames)--according to some of your other posts.
What are the 20 textboxes and 20 labels for?
Labels:
-lblProp1
-lblProp2
...
-lblProp20
TextBoxes:
-tbxProp1
-tbxProp2
...
-tbxProp20
It looks like you are using 7 buttons--some of which seem might be better as options in a MenuStrip.
Buttons:
-btnEditPropList
-btnLockPropList
-btnClearAllProp
-btnPropEditor
-btnConvertFiles
-btnInfoMgr
-btnExitSub
When you say "handwritten", do you mean "hard coded"?
If it contains a " - " after the number, read all directory names using one of the methods in System.IO.DirectoryInfo. To extract the property number, use stringVariableName.Substring(0, stringVariableName.IndexOf ("-") - 2).
If your program fails, how can you re-run it if you delete the original files or overwrite them?
If you need to append to a text file, there are many examples on the web of how to do it. Search the following using your favorite search engine: vb.net append to text file
It sounds like the Windows message that occurs during long running tasks. This occurs because you are executing the long running task on the main thread. The long running operation can occur for multiple reasons. One reason is because it takes that long to complete. Another reason could be resource contention. You should use BackgroundWorkerThread for long running operations.
See the following:
How to use BackGroundWorker to Create Threads
The following is a continuation of my above post.
To serialize the XML (write the XML to file), we will create a static class called "ClsXmlHelper" and add an instance of our "Table" class (ClsTable).
ClsXmlHelper.cs:
public static class ClsXmlHelper
{
//create instance of root attribute (Table) class
public static ClsTable myClsTable = new ClsTable();
}//class
Add the following "using" statements:
using System.IO;
using System.Xml;
using System.Xml.Serialization;
Serializing is quite simple:
public static class ClsXmlHelper
{
//create instance of root attribute (Table) class
public static ClsTable myClsTable = new ClsTable();
public static void serializeToXml(string filename)
{
//writes Xml to file
//create new instance of StreamWriter
StreamWriter sw = new StreamWriter(filename);
//create new instance of XmlSerializer(<your class>.GetType)
XmlSerializer mySerializer = new XmlSerializer(myClsTable.GetType());
//serialize - write data to file
mySerializer.Serialize(sw, myClsTable);
//close StreamWriter
if (sw != null)
{
sw.Close();
}//if
}//serializeToXml
}//class
If you want to eliminate the namespaces and the XML declaration in the XML file, use the following instead:
public static class ClsXmlHelper
{
//create instance of root attribute (Table) class
public static ClsTable myClsTable = new ClsTable();
public static void serializeToXml(string filename)
{
//writes Xml to file
//create new instance of StreamWriter
StreamWriter sw = new StreamWriter(filename);
//create new instance of XmlSerializer(<your class>.GetType)
XmlSerializer mySerializer = new XmlSerializer(myClsTable.GetType());
//eliminate "xsd" and "xsi" namespaces
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add(string.Empty, "urn:none");
//indent Xml and eliminate Xml declaration
XmlWriterSettings myXmlWriterSettings = new XmlWriterSettings();
myXmlWriterSettings.OmitXmlDeclaration = true;
myXmlWriterSettings.Encoding = Encoding.UTF8;
myXmlWriterSettings.Indent = true;
//create instance of XmlWriter …
I haven't used Linq, but if you know how to use Linq with a List, then you should be able to use the following--it uses XmlSerializer. I see a discrepancy in what you posted above. There would be no need to do where GroupName="Name" if the file only contained one GroupName. So, I will assume an XML file that looks like the following:
Table.xml
<Table>
<GroupPermissions>
<Group GroupName="Group1">
<ModuleRestrictions>
<Module1>
<Button1 value="true" />
</Module1>
</ModuleRestrictions>
</Group>
<Group GroupName="Group2">
<ModuleRestrictions>
<Module1>
<Button1 value="false" />
</Module1>
</ModuleRestrictions>
</Group>
</GroupPermissions>
</Table>
To use XmlSerializer, we will use nested classes.
"Table", "GroupPermissions", "Group", "ModuleRestrictions", "Module1", and "Button1" are XML elements (these will be denoted by "XmlElement" or "XmlElementAttribute"). Each one of these will be it's own class.
"Group" contains an attribute named "GroupName". This will be denoted as an "XmlAttribute". Likewise, "Button1", contains an attribute named "value".
In the XML file "Table.xml", more than one "Group" element exists. So, we need to use something that allows for more than one instance of "Group"--we will use a List for this.
Let's get started.
Note: It is necessary to add using System.Xml.Serialization;
statement to each class (file).
You can name the classes anything you want as long as you specify the actual name of the element in the XML file using "ElementName" (if "ElementName" isn't specified, XmlSerializer, will assume that the class name matches the element name). Likewise, with variable and class instance names.
I will start all of the class names with "Cls". …
Yes.
"...Use the SelectedItems or SelectedIndices properties to obtain the selected items in the ListView control, the FocusedItem property is not necessarily selected..."
Here's an online IQ test I found--it's 20 questions. Just something for fun.
And the Breakdown of IQ Scores
"People don't care how much you know until they know how much you care." -- Zig Ziglar
Alternatively, read all text (the entire file). Then use split to split using the line delimiter--storing the result in an array. Then loop through the array as necessary.
The following would be a close translation:
Dim fn As String = "C:\MyTextFile.txt"
Dim sr As New StreamReader(fn)
Dim LineFromFile As String = Nothing
Dim textRowNo As Integer = 0
Dim arrival As String = Nothing
Dim status As String = Nothing
'...
While Not sr.EndOfStream
textRowNo += 1
LineFromFile = sr.ReadLine()
If textRowNo > 8 Then
arrival = Mid(LineFromFile, 1, 9)
status = Trim(Mid(LineFromFile, 11, 3))
'...
End If
End While
sr.close()
Note: The above code is a translation of the code you posted and hasn't been reviewed for efficiency.
Click here for the resource code was translated from.
Use the recovery disks that came with the computer and then repeat the upgrade.
How are you measuring these speeds?
I think that you are going about this the wrong way.
Why are you set in using Notepad to view your file? Have you considered using Wordpad (or Word) to view it? They will display the file correctly if the lines are terminated with CR (or VbCr).
Note: You can change your file association so that .txt files open with Wordpad (or Word).
Why don't you just have the IT person generate the reports in the format that you need them? Surely, it is cheaper to pay the IT person 1 hr (if that) to create the proper reports than to pay you 10 hrs to write your scripts--unless you're doing this on your personal time as an educational experience.
If you still believe that you need to create a script/program to help you modify your reports, I think that you need to start from the beginning. State/show the report that you have and what you would like the end result to be.
There are some questions that need to be answered in order for anyone to be able to provide useful answers.
-What is the folder structure (ie: what are the folder names)? Provide 2-3 fully qualified folder names so one can get an idea of the folder structure.
-What are the file names? (You already provided an answer for this)
-Where do you want to store the converted files? In the original folders?
-What do you want the converted files to look like?
-What do you want the …
In addition, searching for one or more of the following should be helpful: SqlConnection, SqlCommand, DataTable, DataSet.
Btw, you don't look Swedish...hence my confusion earlier. :)
@JamesCherrill: "...why didn't OP see that Exception?"
I ran the code in NB, and it didn't throw an exception. It appears that while(input.hasNextDouble())
doesn't recognize the number as a double and just skips it.
Run the original code and mix numbers using "," (comma) as a decimal separator and numbers using "." (decimal) as the decimal separator in "orange.csv"
68.1
22.3
33,64
Then use the following:
Scanner input;
input = new Scanner(new FileInputStream ("C:\\javamapp\\orange.csv"));
while(input.hasNextDouble()) {
double vikt = input.nextDouble();
weight.add(vikt);
System.out.println("read input: " + vikt);
}//while
Depending on what the decimal separator is set to, it will skip numbers that it doesn't see as doubles. If the decimal separator is set to "," (comma) it will skip numbers in the file with "." (decimal) as the decimal separator. If the decimal separator is set to "." (decimal), it will skip numbers in the file containing a "," (comma) as a decimal separator.
I have been able to replicate NaN in your originally posted code by the following.
Using locale = "en_US" -- English (United States), change numbers (in "orange.csv") to use "," (comma) instead of "." (decimal).
Using locale = "sv_SE" -- Swedish (Sweden), change the numbers (in "orange.csv") to use "." (decimal) instead of "," (comma).
To change locale:
Win 7:
-Start
-Control Panel
-View By: Small Icons
-Region and Language
-Click "Formats" tab
-For "Format", select desired format -- ex: English (United States) or Swedish (Sweden).
-Click "Additional settings" button
-Click "Numbers" tab
-Look at value for "Decimal symbol"
Note: English (United States) only has one choice -- "." Swedish (Sweden) has choice between "." and ","
To find out what the decimal separator on your computer is:
Add the following import statement:import java.text.DecimalFormatSymbols;
Then:
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
System.out.println("Decimal separator for your locale: " + dfs.getDecimalSeparator());
Resources:
Java 7 default locale
Some of your comments in your program were in another language and your profile shows your location as Greece. Didn't really look like Greek, but I don't speak Greek so...
What country is the locale set to for the computer that you are using?
What do you mean by "...did you send that Greek numbers link?" It's something I found when searching for the decimal separator for Greek.
In my opinion the program shouldn't get to the point of NaN. You should check that the array contains data before trying to use it for computations.
I believe that the real issue may be the locale and input settings on your computer. In some European countries, the comma "," is used instead of decimal ".". Check the input language and locale settings on your computer. You may need to change the "." (decimal) to "," (comma) in "orange.csv"
..."Decimals: in Greek, the use of commas and periods is different than in English."
"Period is used to separate the thousands, while the comma is used as the decimal point."
Post the file "orange.csv". What is the range of numbers that is acceptable?
No need to repeat statements that are exactly the same. Just move them outside the if statements. Also, you don't need to use "&&", just order them from high numbers to low numbers (ex: 3999, 2999, 1999, 999, -1). Why remove the "\" only to add it back in. Additionally, LastIndexOf finds the last occurrence of "\", which may or may not be at the end of the path.
if (!path_img2.EndsWith(@"\"))
{
path_img2 = path_img2 + @"\";
}//if
if (imageCounter_img2 > 999)
{
path_img2 += "1";
}//if
else if (imageCounter_img2 > -1)
{
path_img2 += "0";
}//else if
imageCounter_img2 = imageCounter_img2 - 1000;
dir_right.Text = path_img2;
imageno_right.Text = imageCounter_img2.ToString();
Get rid of the second "=" sign. Also your declarations don't match. You have 3 commas, then only 2 commas (and dimensions) in the intialization. The following should work:
int [,] a = new int [3,4] { {2,3,4,5}, {34,56,25,67}, {22,44,55,77} };
See the following for more connection string options. http://www.connectionstrings.com/excel/
I think Jet 4.0 driver only exists in 32-bit.
https://www.connectionstrings.com/using-jet-in-64-bit-environments/
I also became curious. So I timed the execution. On my computer, the method that uses subtraction (as posted above) averaged 600 ms. Then one that uses multiplication averaged 0 ms.
Check it out:
Method 1:
private static String isOddOrEvenMultiply(int num)
{
double tempNumDbl = (double)num * 0.5;
int tempNumInt = (int)tempNumDbl;
double tempNumSubDbl = tempNumDbl - tempNumInt;
int lastDigit = (int)(tempNumSubDbl * 2.0);
if (lastDigit == 0)
{
return "even";
}
else
{
return "odd";
}
}
Method 2:
Note: Some minor modifications were made to the below method. See above for the original supplied by @TylerD75.
private static String isOddOrEvenSubtract(int num)
{
int i = num;
while (i > 2)
{
i -= 2;
}
if ( i == 1 )
{
return "odd";
}
else
{
return "even";
}
}
So, for testing, I added a couple of methods that contain loops. I also added some code to time the execution as well.
Add some variables to hold the elapsedTime:
private static long multiplyElapsedTime = 0;
private static long subtractElapsedTime = 0;
runSubtract:
Note: The following will run 50 iterations.
private static void runSubtract()
{
long startTime = System.currentTimeMillis();
for (int i = Integer.MAX_VALUE; i > Integer.MAX_VALUE - 50; i--)
{
System.out.println("num: " + i + " " + isOddOrEvenSubtract(i));
}//for
long endTime = System.currentTimeMillis();
subtractElapsedTime = endTime - startTime;
//System.out.println("Elapsed time (subtraction): " + subtractTotalTime);
//test with negative numbers
for (int i = 0; i > -10; i--)
{ …
@Tarek_2: That might be ok for small numbers, but what about when you approach Integer.MaxValue (2,147,483,647)?
You're being somewhat cryptic. The name of the program would be useful. Also a screen shot of the window may be useful. Additionally, how much time do you spend each day copying data from the screen?
Do you have sleep/hibernation disabled (or set to "Allow wake timers") on the workstation? Are you able to rdp to this workstation from any other computer (on the same side of the router or remotely)?
Check value of the following registry keys on workstation:
Check that workstation is listening on the port:
should see something like 0.0.0.0:3389 (where 3389 is the PortNumber from the registry key)
When you attempt to connect are you typing "Domain\username" or "username"? Try both.
Are you connecting remotely using the IP Address? If you are connecting locally (inside the network), do you use the the IP Address or name? (When on a domain, you may have to type: name.local)
Resource:
Remote Desktop for Windows 8
The answer may depend on where you are trying to get the data from. Web browser? Java applet? Word? etc...
Are you using all of the standard OEM components? Or did you upgrade other things such as the video card? Video cards can use lots of power. If you upgraded the video card, there may not be any excess power left.
Change lines 40-42
from:
i += 1
TextBox1.Text = dt.Rows(i)(0)
TextBox2.Text = dt.Rows(i)(1)
to:
'last index is dt.Rows.Count - 1
'only increment if doing so
'would not exceed the index
If i < dt.Rows.Count - 2 Then
i += 1
Else
'set to the last row
i = dt.Rows.Count - 1
End If
If dt IsNot Nothing Then
TextBox1.Text = dt.Rows(i)(0)
TextBox2.Text = dt.Rows(i)(1)
End If
If you are going check the last character of a string, you could convert to binary and then just check for "0" or "1".
public static String isOddOrEven(int num)
{
String binaryStr = Integer.toBinaryString(num);
if (binaryStr.charAt(binaryStr.length() - 1) == '0')
{
return "even";
}
else
{
return "odd";
}
}
Is this a homework assignment? If so, I think that you're missing the point of the lesson. What is the current subject matter? Some possible lessons that are trying to be taught are:
The following will (eventually) result in an invalid result because of the effects of numeric approximation, rounding and truncation:
private static String isOddOrEven10(int num)
{
String result = "";
double tempNumDbl = (double)num * 0.1;
int tempNumInt = (int)tempNumDbl;
double tempNumSubDbl = tempNumDbl - tempNumInt;
int lastDigit = (int)(tempNumSubDbl * 10.0);
//int lastDigit = (int)((tempNumDbl - (int)tempNumDbl) * 10.0);
switch(lastDigit)
{
case 0:
result = "even";
break;
case 2:
result = "even";
break;
case 4:
result = "even";
break;
case 6:
result = "even";
break;
case 8:
result = "even";
break;
default:
result = "odd";
}//switch
return result;
}
Output:
Num: 41
41.0 x 0.1 = 4.1
(int)4.1 = 4
4.1 - 4 = 0.10000000000000053
0.10000000000000053 x 10.0 = 1.0000000000000053
(int)1.0000000000000053 = 1
Result: 1 is odd, so 41 is odd.
Num: 42
42.0 x 0.1 = 4.2
(int)4.2 = 4
4.2 - 4 = …
In "frmBirthdayCake_Load", the connection is not open. Where is con.Open
?
Use Nltest to test trust relationship
nltest
nltest /server:<server name> /sc_query:<domain name>
nltest /server:<server name> /sc_verify:<domain name>
/sc_query: <DomainName>
Reports on the state of the secure channel the last time that you used it. (The secure channel is the one that the NetLogon service established.) This parameter lists the name of the domain controller that you queried on the secure channel, also.
/sc_verify: <DomainName>
Checks the status of the secure channel that the NetLogon service established. If the secure channel does not work, this parameter removes the existing channel, and then builds a new one. You must have administrative credentials to use this parameter. This parameter is only valid on domain controllers that run Windows 2000 with Service Pack 2 and later.
Here are a few ideas:
Ensure that "Don't allow connections to this computer" is not selected (on workstation)
Open "System Properties"
Then:
If you made changes, re-test your connection.
Reset computer account
Alternatives:
Netdom resetpwd
Powershell Reset-ComputerMachinePassword
After resetting the computer account, perform a backup of the workstation.
Re-join workstation to domain.
Trust Relationship Between Workstation and Domain Fails
If the Secure Channel is Broken between Domain controller and workstations
...A common cause of broken secure channel [machine account password] is that the secure channel password held by the domain member does not match that held by the AD. Often, this is caused by performing a Windows System Restore (or reverting to previous backup or snapshot) on the member machine, causing an old (previous) machine account password to be presented to the AD...
Resolution:
Most simple resolution would be unjoin/disjoin the computer from the domain and rejoin the computer account back to the …