Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
S

Scott Page

@Scott Page
About
Posts
28
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Incorrect Time in DateTime column with MS Access database
    S Scott Page

    Problem solved. Solution: Change all DataAdapter DateTime columns Input and Update parameters OleDbType to DBTimeStamp. By default the designer sets any Date/Time column to DBDate which only formats the data to store the date. This goes for DataAdapters created by the designer and for manually coded OleDbParameters.

    "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    Database help csharp database visual-studio

  • export to excel through asp page(not asp.net)
    S Scott Page

    You're in a .NET board. Repost your question to a board that deals with ASP if you expect an answer.

    "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    .NET (Core and Framework) help csharp asp-net question

  • Do Events causing overflow
    S Scott Page

    Is this method called from within an event handler? If so, calling DoEvents may be refiring the same event and calling your code again, and again while you are still inside of the While loop. I would suggest removing the event handler at the begining to the SaveImageToFile method, then adding the handler at the end. This can also be done within the Event handler method as well. I have had way to many headaches for this problem to hit me again, and 99% of the time, it's because the event is being fired before your code completes. Hope this helps, Scott Page

    "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    .NET (Core and Framework) graphics csharp c++ data-structures

  • Let user add new items to a databound combobox
    S Scott Page

    I would suggest not binding to the combobox using the DataSource property as a solution. I'll give you a rough example, though I haven't tested it, I know it is possible. Assuming the following: A ComboBox named 'cboItems' A Button named 'btnUpdate' A TextBox named 'tbItemName' A Typed-DataSet named 'dsData' of type ExampleDataSet A Typed-DataTable in 'dsData' named 'ExampleItems' of type ExampleDataTable A DataColumn in 'ExampleItems' named 'ItemName' Public Sub Form_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load 'We will implement custom sorting, so disable the ComboBox automatic sorting Me.cboItems.Sorted = False Me.RefreshItems End Sub Private Sub RefreshItems 'Create a temp StringCollection to sort our data Dim SortedItems As New Collections.StringCollection For Each IRow as ExampleDataSet.ExampleRow In Me.dsData.ExampleItems SortedItems.Add(IRow.ItemName) Next 'Sort the list before adding it to the ComboBox SortedItems.Sort Me.cboItems.Clear Me.cboItems.BeginUpdate 'Begin updating the combobox, recommended but not required all of the time 'Add the "Add New Item" first to ensure it is the first item Me.cboItems.Items.Add("Add New Item") For Each Name As String In SortedItems Me.cboItems.Items.Add(Name) Next Me.cboItems.EndUpdate 'Finished updating the combobox SortedItems = Nothing 'At this point, our ComboBox has at least one item "Add New Item" so we can safetly 'set the ComboBox.SelectedItem to 0 Me.cboItems.SelectedIndex = 0 'Alternative 'Me.cboItems.SelectedIndex = Me.cboItems.Items.IndexOf("Add New Item") End Sub Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAdd.Click Me.dsData.ExampleItems.AddExampleItemRow(Me.tbItemName.Text) 'After adding an item to the datasource, refresh the list to reflect the changes 'This can be done after deleting a row or updating it as well Me.RefreshItems End Sub The previous example will work. However, I would suggest possibly using a button on the main form that opens a child form when clicked. The child form would have all of the controls needed to add the item. When the child form closed you could then add an item. This would allow you to bind directly to the combobox and not worry about all of the previous code. Hope this helps, If you have any other questions feel free to ask Scott Page "Some people spend

    Visual Basic help

  • DateTime in MS Acces with ADO.NET
    S Scott Page

    I posted this question on the ADO.NET board, but the only reply I got was that I need to check my Update code. I have an Access database with a Date/Time column. I used the VS.NET forms designer to create an OleDbDataAdapter and DataSet from the datasource. The DataSet created has the Date/Time column with a DateTime type as expected. The Fill and Update methods work properly without exception. However, after an insert or update, the data that actually gets stored to the database has a time of 12:00:00 AM, requardless of the time I specified while running the application. One solution I have thought of, but not tried, is to change all DateTime column types in the Typed-DataSet to OleDb.Date. Thanks, Scott Page

    "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    Visual Basic csharp database visual-studio help question

  • Problem with thread
    S Scott Page

    You're going to need to post some code to get an answer for this one. There could be a number of reasons. Post only the code that starts the thread, the code run by the thread, and the code that terminates the thread, for now. I'll take a look and give you any advice I can come up with.

    "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    Visual Basic help csharp dotnet workspace

  • Incorrect Time in DateTime column with MS Access database
    S Scott Page

    The DataSet and INSERT statement where both created by the designer using a DateTime type for the column in code. The database is set to for Date/Time datatype. Even when I have tried to update it manually using SQL and oledb commands, the resulting query returns the same... Correct date, 12:00:00 AM time. There is a workaround somewhere, I've used it a few years back, but not recently enough to remeber what it was. In the mean time, I changed the field datatype in the database to Numeric - Double. In my code I add a column at runtime and convert the OADate (Double) to a .NET DateTime type and disply the DateTime.ToShortDateString in generated column, then map that to my ComboBox DisplayMember property. It works, but shouldn't be that way. Thanks for the help

    "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    Database help csharp database visual-studio

  • Incorrect Time in DateTime column with MS Access database
    S Scott Page

    I have a table in an MS Access database with a Date/Time datatype for one of the fields. I generated a DataSet using a OledbDataAdapter in the VS.NET 2003 Forms Designer from the table mentioned previously. Everything works as expected during Fill and Updates. My problem is that the DateTime displays the Date portion correctly, but the Time is constantly 12:00:00 AM, not the time that was inserted. I recall seeing this problem a few years ago, but I have forgotten the solution and all of my searches come up empty. Any help would be greatly appreciated! Thanks, Scott

    "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    Database help csharp database visual-studio

  • Calculating values in a datagrid
    S Scott Page

    I would suggest enumerating all rows of the datasource (datatable) and summing up each value from the target column. It would look something like this: (assuming there is a DataTable already created called DT

    Dim Total As Double = 0#
    For Each R As DataRow In DT.Rows
    Total += R(1) 'This line simply adds the value from Column 1 of the current row.
    Next
    Me.label1.Text = Total.ToString() 'Set the labels text property to display the total.

    If you have a strongly typed DataTable, you may have access to the Properies of each DataRow to use instead of getting the column data using the index of in the row. For example R.Price instead of R(1). Hope that does the trick. "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan) -- modified at 21:50 Monday 28th August, 2006

    Visual Basic csharp question

  • Sum algorithm
    S Scott Page

    Thanks to All for your help, Here is the code that has worked on several target height values passed. (Not quite sure how this "code" thing works yet) 'This function exists within a custom collection Public Function GetStack(ByVal height As Decimal) As GageBlockCollection Me.ClearUsedBlocks() Dim Stack As New GageBlockCollection If Me.HasEqualGageBlock(height) Then Stack.Add(Me.GetEqualGageBlock(height)) Return Stack Else Dim PossibleBlocks As New GageBlockCollection If height >= 1 Then 'Height is greater than 1", so find the block that makes eliminates the inch part For Each Block As GageBlock In Me If height - Block.Height > 0 AndAlso height - block.Height < 1 Then Block.IsUsed = True PossibleBlocks.Add(block) height -= Block.Height End If Next End If 'Find all Blocks that are smaller than height For Each Block As GageBlock In Me If Block.Height < height AndAlso Not Block.IsUsed Then PossibleBlocks.Add(block) End If Next 'Find combinations of blocks that are less that height Dim Done As Boolean = False For Each Block1 As GageBlock In PossibleBlocks For Each Block2 As GageBlock In PossibleBlocks If height - (Block1.Height + Block2.Height) = 0 Then Block1.IsUsed = True Block2.IsUsed = True Stack.Add(Block1) Stack.Add(Block2) Done = True Exit For End If Next If Done Then Exit For End If Next For Each Block As GageBlock In PossibleBlocks If Block.IsUsed Then Stack.Add(block) End If Next Return Stack End If End Function Thanks again, Scott Page "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    Visual Basic algorithms data-structures help tutorial

  • Sum algorithm
    S Scott Page

    Thanks for the post, I am getting closer to my goal, but still no cigar (I mean stack). Below is the function I'm using to build the stack. In answer to you question about the 0.06" height, Block Sets are manufactured to cover nearly all possible heights seen in the manufacturing and Metrology worlds. If a value does not exist, there other methods used to measure those dimensions. This function gets me as close as 2.203". I tested the function using 2.203" (correct result), 2.205" (still got 2.203"), 2.305" (still got 2.203"). The returned stack has the 0.101", 0.102" and 2" blocks used, so obviously, since I can't use the 0.102" block, I can't cover the last 0.102" of the height. The Code: 'This function exists within a custom collection Public Function GetStack(ByVal height As Decimal) As GageBlockCollection Me.ClearUsedBlocks() Dim Stack As New GageBlockCollection If Me.HasEqualGageBlock(height) Then Stack.Add(Me.GetEqualGageBlock(height)) Return Stack Else Dim PossibleBlocks As New GageBlockCollection If height >= 1 Then 'Height is greater than 1", so find the block that makes eliminates the inch part For Each Block As GageBlock In Me If height - Block.Height > 0 AndAlso height - block.Height < 1 Then Block.IsUsed = True PossibleBlocks.Add(block) height -= Block.Height End If Next End If 'Find all blocks that are less than the remaining Height (the inch part has been removed) For Each Block As GageBlock In Me If Not Block.IsUsed AndAlso Block.Height <= height AndAlso Block.Height.ToString.Length = height.ToString.Length Then If Block.Height = height Then Stack.Add(Block) Block.IsUsed = True For Each B As GageBlock In PossibleBlocks Stack.Add(B) Next Return Stack Else Stack.Add(Block) Block.IsUsed = True height -= Block.Height End If End If Next If Not height = 0 Then For Each Block As GageBlock In PossibleBlocks

    Visual Basic algorithms data-structures help tutorial

  • Sum algorithm
    S Scott Page

    Thanks, that's a big help. I'll post some code after I compile it. Thanks again, Scott Page "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    Visual Basic algorithms data-structures help tutorial

  • Sum algorithm
    S Scott Page

    I work for Lockheed Martin as a Metrologist, this is for personal and work related intrests. There would be no reason for this message board to exist if it wasn't here to help others out. I give my 110% and rarely ask for 1% in return, all I need is a faster way to build a Gauge Block stack. Thanks for the post. "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan) -- modified at 16:02 Wednesday 5th April, 2006

    Visual Basic algorithms data-structures help tutorial

  • reset form
    S Scott Page

    Make sure you are setting the .Text property to "" or String.Empty. You are attemting to set the Controls (TextBox1, TextBox2, etc.) to Nothing. Example TextBox1.Text = String.Empty This also works TextBox1.Clear Hope this helps :-D "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    Visual Basic json help question

  • Sum algorithm
    S Scott Page

    :confused::confused::confused: I have a collection of objects (in this case, the objects are "Gauge Blocks"). Each Block in the Set (collection) has a length (i.e. 0.1009", 0.101"...). There are 81 Blocks in a Set. I need an algorithm that will determine what combination of Blocks are needed to build a stack for a given value of measurement, using the least amount of Blocks to build the stack. Also, I cannot use the same Block twice, because the Set only has one of each Block. Example: The inner width of the device being tested is 2.305". To manually build the stack from an 81 Block Set (or whatever size Set), I would normally start from the right most value of the tested dimension. In this case 5 is the right most value. I would locate a Block that has the same precision (2.305" has 3 digits of precision), so I would select a Block that has a 5 in the 3rd decimal place (i.e. 0.105" - The Blocks in each Set are NOT linear from 0.0001" to 4" in 0.0001" steps, which is why this is not as easy as I wish it was). Next I would find the next Block in the Set (2.305" - 0.105" = 2.200"), which is 0.2". That leaves me with 2", I use the 2" Block for a remainder of 0". The typical Gauge Block Set includes the following values: 0.05,0.10,0.1001,0.1002,0.1003,0.1004,0.1005,0.1006,0.1007,0.1008,0.1009,0.101,0.102, 0.103,0.104,0.105,0.106,0.107,0.108,0.109,0.110,0.111,0.112,0.113,0.114,0.115,0.116, 0.117,0.118,0.119,0.120,0.121,0.122,0.123,0.124,0.125,0.126,0.127,0.128,0.129,0.130, 0.131,0.132,0.133,0.134,0.135,0.136,0.137,0.138,0.139,0.140,0.141,0.142,0.143,0.144, 0.145,0.146,0.147,0.148,0.149,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50,0.55,0.60,0.65, 0.70,0.75,0.80,0.85,0.90,0.95,1,2,3,4 "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    Visual Basic algorithms data-structures help tutorial

  • store String chars or substrings in Array
    S Scott Page

    Strings have a "Chars" property array, which is the string split into an array of characters, just like what you are wanting. For Example. Dim S As String = "Test" S.Chars(0) ' contains T S.Chars(1) ' contains e S.Chars(2) ' contains s S.Chars(3) ' contains t You can also use the "ToCharArray" function of a String to get a specific substring of the string and split it into a character array. For Example. Dim S As String = "Test" S.ToCharArray(2, 2) ' returns "st" because s is the the third index 'of "Test" (zero based array) and the length of the returned array (second 'parameter of the ToCharArray function) is 2. Hope this helps, Scott "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    Visual Basic database data-structures question

  • Array handling
    S Scott Page

    I deal with large amounts of data on a regular basis as well, and most of the time I only need to manipulate a small portion to get the results I need. I'm not sure if this applies to your problem, but if you know the specific points you need, you could reference that location within the array and calculate a smaller amount of data. If you need all of the data and can't live without any of it, then as far as I know right now, processing 120 million data points is just a slow process no matter how you code it. Sorry I couldn't provide more help, hope someone knows of a solution for you. Scott

    .NET (Core and Framework) csharp question css data-structures

  • Array handling
    S Scott Page

    Try using the System.Collections.ArrayList. You'll be surprised, but the ArrayList is 100's of times faster than an Array. Enumeration is also lightning fast compared to the Array. It's all I use unless some prebuilt function just must use the standard Array. The ArrayList is also Dynamic, which means it can shrink and grow automatically without the need to "Redim" or move values in and out of one Array to the next. One quick note about the ArrayList constructor. It must be instantiated by calling the New method, unlike the Array - Dim TestArray(15) As String, you must create the ArrayList, Dim TestArrayList As New ArrayList, then add to it like this... TestArrayList.Add(_Value_). Hope this helps, Scott Page

    .NET (Core and Framework) csharp question css data-structures

  • Learning programming using VB.NET
    S Scott Page

    Hi Mark, I just purchased and finished reading this book Mastering Visual Basic.NET[^] from Sybex. The coding starts out very basic and moves through VS.NET and the VB.NET classes. The coding may be just barely over his head at 13, but if he's making A's in school I'm sure the reading context is right at his level. Otherwise, I have read several of the "Dummy" series of books relating to VB.NET, ASP.NET and Database technology, all of which where great reads because the content is almost humorous but can teach even the most veteran of us a few things here and there. Hope this helps! Scott Page

    Visual Basic csharp question career learning

  • validating data entry in vb.net forms, use regular expressions?
    S Scott Page

    It sounds to me like you may just (maybe not "just", but.. ;P) need to make a few user controls (or design a custom control) that encapsulate all of the required functionality. You can set properties within the controls that are readonly (those that you do not wish to have modified by the developers). The following Sites/Articles may provide useful, as they speak in reference to your question(s). http://builder.com.com/5100-6387_14-5025318.html[^] http://www.thecodeproject.com/useritems/Regular_Expression.asp?print=true[^]

    Visual Basic csharp question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups