Another give me code request from another I'm too lazy to search myself poster.
http://letmebingthatforyou.com/?q=gaussian%20filter%20vb6
hint it's on planetsource code
Another give me code request from another I'm too lazy to search myself poster.
http://letmebingthatforyou.com/?q=gaussian%20filter%20vb6
hint it's on planetsource code
I'm glad it is working. One comment: Drop the type conversions, they are not necessary and the "New String" is a waste of resources.
ObjArr(0) = CObj(New String(Latitude))
becomes
ObjArr(0) = Latitude
You have indicated that you have a database. Why not store the info there?
What type of database is it?
Registry based systems are easy to crack. Usually, all it takes is for the user to identify which key your program has added and delete it to reset the counter.
How is that any different than before? It still changes the combobox items on the Dropdown event. I assume that the list of students does not change during your program run, so fill the items array once in either the FormLoad or FormShown event handler.
First off, thankyou for a well written question. These are so rare in this forum.
Second, I have never done what you are doing, but I have read on it, so take my advice with a grain of salt.
Me.WebBrowser1.Document.InvokeScript("addMarker", New String() {"41.850033, -87.6500523"})
I believe that you may need to pass your string in an Object array instead of the string array.
From the documentation: http://msdn.microsoft.com/en-us/library/4b1a88bz.aspx
Private Sub InvokeTestMethod(ByVal Name As String, ByVal Address As String)
If (Not (WebBrowser1.Document Is Nothing)) Then
Dim ObjArr(2) As Object
ObjArr(0) = CObj(New String(Name))
ObjArr(1) = CObj(New String(Address))
WebBrowser1.Document.InvokeScript("test", ObjArr)
End If
End Sub
Perhaps it has something to do with the fact you are querying the DB on the combobox.Dropdown event and trying to change it's datasource in that same handler.
ComboBox perspective - I dropDown to display my content, but wait, the programmer wants to change my contents while the I'm is trying to display them. I need an asprin!
I've never been to Winnipeg, but the mosquito is the unofficial state bird. :). Last summer I think Minneapolis had the distinction of being the hottest city in the nation twice when we were in the low 100's F
Thankfully, I have not yet seen any Asian Tiger Mosquitos since I moved here 10 years ago. The first time I encounted one of those was when I lived in Illinois and was cutting my lawn when it felt like some stabbed me in the thigh with a pencil. I did the instinctual slap and on inspection I thought WTH is that mutant thing. An hour of reseach later, I knew the answer; another lovely invasive species brought in from Asia.
Oh, joy! I decide to check on their distribution, and the CDC has a confirmed hit (http://www.cdc.gov/ncidod/dvbid/arbor/albopic_97_sm.htm just east of me.
Oh, Alberta, please send down 2 weeks worth of those clippers to freeze out those critters!
The StringCollectionEditor is for editing an object of type System.Collections.Specialized.StringCollection or a class that inherits from it. It implements all the interfaces you have specified for your class, but have provide the methods that specifying those interface requires you to do?
See: http://msdn.microsoft.com/en-us/library/87d83y5b%28v=VS.80%29.aspx
Also, you may need to change "System.Windows.Forms.Design.StringCollectionEditor" to "System.Windows.Forms.Design.StringCollectionEditor, System.Design"
That's one thing about the cold - you can always throw on another sweater. Can't do much on the hot days except sweat.
I've always said this about the heat and humidity: "once yuo hit skin, there's nothing more to take off except the sweat".
I believe that the OP's reasoning may be valid if another application is accessing the DB as well. If both tried to grab total access at the same time, there may be a conflict.
Assuming that you made a typo on the forum (missing opening quote) with the connection string, the second version (Mode=Read;) should prevent you from executing insert/update commands. And yes, I have verified that it blocks writing; it throws an invalid update command when executing.
Would not changing the "Full Name" field in your User Profile accomplish the same goal?
Unless, your Username is something you find to be unprofessional.
Yes, of course. Embedding a file just merges a copy of it into the executable. The My.Resources provides it a Byte array. There are also tools that allow you to retreive it is as an IO.Stream.
Edit: Some programs may what to have the proper extension (.wmv, .jpg, etc.) and a temporary filename will have a ".tmp" extension. You can rename a file using System.IO.File.Move("oldpath\filename", "oldpath\newfilename") or you can use the VB helper method My.Computer.FileSystem.RenameFile.
I'm sorry, but I do not understand what you are trying to ask.
Ok. You now got it as an embedded resource, so for the player to play the movie, you will first have to write it to the disk. I like using temporary files for this.
Public Class Form1
Dim tempfile As String = System.IO.Path.GetTempFileName
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strmTemp As IO.Stream = IO.File.Create(tempfile, 1024, IO.FileOptions.None)
strmTemp.Write(My.Resources.back_blue, 0, My.Resources.back_blue.Length)
strmTemp.Close()
AxShockwaveFlash1.Movie = tempfile
End Sub
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
' delete the temp file
System.IO.File.Delete(tempfile)
End Sub
End Class
It can be done. However, the sucess of the implementation depends on how dependent the hosted program is on being parented to the Desktop Window and how good the developer is at developing workarounds for those dependencies. A program like Notepad is trival while hosting MS Word can make you want to cry out for your mamma.
That said, here is an example of my attempt at writing a generic Panel derived control for hosting an application.
Use this code at your own risk, Do not expect me to provide any support or explanation of its workings.
I have relegated further work on this type of endeavor to only be done when I have nothing better to do, like beat myself in the head with a lead pipe.
Start off with a new WinForm application. Add new class and replace its generated code with this.
Imports System.Runtime.InteropServices
Public Class HostApplicationPanel
Inherits Panel
Private Const WM_Close As Int32 = &H10
Private AppProcess As Process
Private AttachedToFormClosing As Boolean = False
Public Sub StartApplication()
If Not AttachedToFormClosing Then
AttachedToFormClosing = True
AddHandler Me.FindForm.FormClosing, AddressOf MyFormClosing
End If
If AppProcess IsNot Nothing AndAlso Not String.IsNullOrEmpty(AppProcess.MainModule.FileName) Then
Select Case MessageBox.Show("Terminate " & AppProcess.MainModule.FileName & " ?", "Panel Has Application", MessageBoxButtons.YesNoCancel)
Case DialogResult.Yes
CloseApplication()
AppProcess.Close()
Case DialogResult.No
Exit Sub
End Select
End If
ApplicationStartInfo.CreateNoWindow = False
ApplicationStartInfo.WindowStyle = ProcessWindowStyle.Maximized
Try
AppProcess = Process.Start(ApplicationStartInfo)
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
AppProcess.WaitForInputIdle(5000) 'Give application a max of 5 seconds to return InputIdle
'Debug.WriteLine(Me.Name.Trim …
First off, .Net will be slower than a natively compiled VB6 app.
One thing to check for is late binding of objects. This will really slow things down. If you have not already done so, add the following to the top of your code and then the fun begins; work through all of the IDE error and warning messages.
Option Strict On
not necessary but I also recommend:Option Explicit On
- Inferred by using Option StrictOption Infer Off
References:
Option Explicit and Option Strict in Visual Basic .NET and in Visual Basic
What you want to do is turn off the power supply switch via a software command. I have never seen this type of functionality and do not believe it exists at least not in any published standard.
From the ACPI Specification: http://acpi.info/DOWNLOADS/ACPIspec40a.pdf
A.2.2 Display Power Management
Refer to the Display Power Management Signaling Specification (DPMS), available from:
Video Electronics Standards Association (VESA)
2150 North First Street
Suite 440
San Jose, CA 95131-2029
A DPMS-compliant video controller and DPMS-compliant monitor use the horizontal and vertical sync signals to control the power mode of the monitor. There are 4 modes of operation: normal, standby, suspend and off. DPMS-compliant video controllers toggle the sync lines on or off to select the power mode.
For more entertaining reading: http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/DspPMSpc.rtf
I do not see anything in your implementation that should be causing a problem. There is not much to this, so I do not understand why it did not work for you. I'm attaching my implementation.
The only thing I question is your setting the RTB.Size to the form size, but that will not cause an issue. Why not set RTB.Dock=Fill?
What is your development environment?: OS, VS version, 32 or 64 bit?
The only thing that could through a nul exception in that statement is "app".
Make sure that app has a value. Add a "Stop" statement likes this, and then inspect app.
' start Excel
app = CType(GetObject("", "Excel.Application"), Microsoft.Office.Interop.Excel.Application)
Stop
Another option is to modify the app declaration to be like this (add "New" to it):
Private app As New xl.Application ' need this common
and then delete:
' start Excel
app = CType(GetObject("", "Excel.Application"), Microsoft.Office.Interop.Excel.Application)
This will lock you into the particular version of Excel that you imported though.
Yes. I see no need for it. Once you force the browser to create a blank document, you access that docment directly and modify it's text.
Just curious, what is the point of this other than to see if you can do it?
To be honest, I have not tried your code. It's the end of the day, well almost the start of the next, but I did not want to leave you hanging.
I am giving you an alternate method that I have tried and it works.
I assumed that you child forms are MDIChildren, but that does not matter as it work even if not a MDI project.
Form1: MDIParent
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Form2.MdiParent = Me
Form2.Show()
Form3.MdiParent = Me
Form3.Show()
End Sub
End Class
Form2: Child with RTB
Public Class Form2
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
Form3.wb1.DocumentText = RichTextBox1.Text
End Sub
End Class
Form3: Child with WB
Public Class Form3
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
wb1.Navigate("about:blank") ' forces it to create a document
End Sub
End Class
That is a shorthand notation that VB allows you to do. In my Import statement I defined xl to be equal to the full declaration.
Imports xl = Microsoft.Office.Interop.Excel
The Ctype is required in my code because I program with
Option Strict On 'no implicit narrowing conversions
Option Explicit On 'all variable must be defined in a Dim statement
Option Infer Off ' no type inference, no Dim fred without an "As Something"
and the wb.Worksheets("Sheet1")
returns a Worksheet boxed in an Object. A direct assignment would involve an implict narrowing conversion to Excel.Worksheet. Option Strict disallows implicit narrowing conversions.
I prefer to have everything explicit in regards to type definitions.
It's a bit extra typing, but the payback is less chance errors by using the wrong type. The IDE flags its, I take a second to think about what I really meant and 90% of the time I can select a correction from those offered by the IDE; so it eliminates some of the extra typing with two mouse clicks.
Some will also disagree with my choice of Option Infer Off, but to me infer = compiler make a guess about what I mean. Guessing my intent is something that makes me ill when it comes to my code.
Its bad enough that I occasionally type in absolute garbage that is perfectly valid as far as the compiler is concerned. ;)
activate focus to the textbox after keypress
But what is going on in the keyup event handler that is causing it to loose focus? Setting focus may be the ultimate answer, but right now it is more like treating the symptom than the problem.
Please show your key handler code. Based on your description I can only surmise that you are some how feeding the key character into the webbrowser.Document text, but that is only a guess. It is hard to offer advice when we have to guess what you are doing.
@Jim,
I see that you been over on the MSDN forum and found KevinInstructor's (I think that's his tag) ReleaseObject method that he promotes.
That method can still fail if do not follow the One-Dot rule when delcaring a reference to a ComObject.
This code follows the One-Dot rule.
' start Excel
app = CType(GetObject("", "Excel.Application"), Microsoft.Office.Interop.Excel.Application)
' open the workbook
Dim wb As xl.Workbook = app.Workbooks.Open("D:\My Documents\Spreadsheets\TestRangeInterop.xlsx")
' get Sheet1
Dim worksheet As xl.Worksheet = CType(wb.Worksheets("Sheet1"), Microsoft.Office.Interop.Excel.Worksheet)
This does not.
' start Excel
app = CType(GetObject("", "Excel.Application"), Microsoft.Office.Interop.Excel.Application)
' get Sheet1
Dim worksheet As xl.Worksheet = CType(app.Workbooks.Open("D:\My Documents\Spreadsheets\TestRangeInterop.xlsx").Worksheets("Sheet1"), Microsoft.Office.Interop.Excel.Worksheet)
Both get a reference to the worksheet, but the second one causes a non-referenced ComObject (the workbook) to be created. This unreferenced object is tied to Excel and excel is tied to it. So, if you application, ends this reference can not be disposed of and hangs around keeping Excel open.
If you create a reference to it as in the first code block, you can set that reference to Nothing thereby allowing the Garbage collection mechanism can get rid of it.
At least that is my understanding of it and it works for me.
These types of headaches are why I've become an advocate of the open XML document format and the use of Open XML SDK 2.0 for Microsoft Office.
Iterating through a column as shown above will find the first empty cell, but not necessarily the last used cell in the column. If your user happens to leave one of the textboxes empty, you risk overwritting previous stored information. This could be handled by making sure each textbox is not empty but what happpens if someone edits the spreadsheet and accidently clears a cell?
A technique like shown below will find the last used cell in a column.
Imports xl = Microsoft.Office.Interop.Excel
Public Class Form1
Private app As xl.Application ' need this common
Private Const MaxRows As Int32 = 1048576 ' Max rows in Excel 2007 - adjust for your version
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' start Excel
app = CType(GetObject("", "Excel.Application"), Microsoft.Office.Interop.Excel.Application)
' open the workbook
Dim wb As xl.Workbook = app.Workbooks.Open("D:\My Documents\Spreadsheets\TestRangeInterop.xlsx")
' get Sheet1
Dim worksheet As xl.Worksheet = CType(wb.Worksheets("Sheet1"), Microsoft.Office.Interop.Excel.Worksheet)
' get the last used cell in column A
Dim LastCell As xl.Range = LastUsedCellInColumn(worksheet, "A")
Dim NextEmptyCell As xl.Range
Try
If LastCell Is Nothing Then
' nothing used in column A
NextEmptyCell = worksheet.Range("A1")
Else
If LastCell.Row = MaxRows Then
Throw New Exception("Column is full")
End If
' move down one row
NextEmptyCell = LastCell.Offset(RowOffset:=1, ColumnOffset:=0)
End If
LastCell = Nothing
' do what you need to do with the cell address
MsgBox(NextEmptyCell.Address)
Catch ex As Exception
MsgBox(ex.Message)
Finally
' clean up
NextEmptyCell = Nothing
worksheet = Nothing
wb.Close()
wb = Nothing
app.Quit()
app = …
Why stop at SQL 2008? We have clients with SQL 2012...
I guess no reason other than I believe that you would need to connect via the SQL Server Native Client OLE DB provider with your DataSource objects.
Unless you have an absolute need to be using SQL Server 2005, I would recommend against installing it and go directly for SQL Server 2008.
You will need to get the VS2008 updates to work with it, but it is nice to work with the new SQL version. Plan on a long update process for the VS2008 installation; their have been many over the years.
Directory.CreateDirectory(x.myCriticalFolder)
-> ok so no final "\" on myCriticalFolder. But then,
Dim path As String = myCriticalFolder & "Locations and Call Types.txt"
Missing the "\" between folder and filename
You could use: IO.Path.Combine(x.myCriticalFolder, "Locations and Call Types.txt")
instead.
Have you tried to use a timer to execute your turn-off code?
Have you added the file as an embedded resource?
i.e. can you type in your code: My.Resources.back_blue ?
If so, you will need to extract it to disk first.
You have two linked pieces of data: 1) username and 2) their password. To make this work, the username needs to be unique. This is why when signing up for any type of service that requires an username and password, that the service checks the availabilty of the selected username.
Since you have stated that your can not use the built-in databases, the next best thing to do would be to create some type list of (username, passord) pairs. The ideal .Net structure for this would be a Dictionary(Of string, string). Dictionary Generic Class
The key will be the username and the value will be the password.
Read through the documentation on its methods (hint: ContainsValue).
You have control over the textfile, so I would suggest that you use a simple delimitted file format. Comma delimitted is very common.
If you need to write a file you will be using System.IO.Stream and System.IO.StreamWriter.
To read a delimitted file, VB provides you a class to help with that.
How to: Read From Comma-Delimited Text Files in Visual Basic
Here is a very crude webbrowser example that maintains two history listes. It may give you some ideas. This example uses datatables instead of a string collection.
I don't use CR but it looks similar to using MS's RDLC.
I believe that you need to create a parameter field for your textobjects. Here is a reference:
http://www.informit.com/articles/article.aspx?p=683066&seqNum=1
This link shows how to set the parameters at runtime.
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/aee2d970-470f-4cfe-9765-cbf50c28bf24
Well gee, with such an informative description of the problem, all I can say is you did it wrong.
Yes. Just change:
current.Offset(0, 1).NumberFormat = "[$" & [SelectedCurrency].Value & "] #,##0.00"
to a Select Case block.
Select Case [SelectedCurrency].Value
Case "USD"
current.Offset(0, 1).NumberFormat = "$ #,##0.00"
Case "EUR"
current.Offset(0, 1).NumberFormat = "€ #,##0.00"
etc.
End Select
http://letmebingthatforyou.com/?q=excel%20lookup%20table
Hint: Look at the Microsoft support article.
This was it, TnTinMN! Thanks for the help. Any idea why we can't just update through the defaultview? It seems like a real hole in the environment logic to have to update the table on it's own terms not using the defaultview portal..
Sorry for taking so long to get back to. It slipped my mind.
A DatagridView is well just that, a view on the data that is supplied to it. In this case the source data is a DataView that is again a view of the DataView underlying data source that can be filtered and sorted to satisfy a particular requirement. It is not meant to be the data itself.
From the DataGridView you can find data source as that is a property of each datagridviewrow. These are stored as objects, so you need to know the original source type. In the case of a DataView, it is a DataRowView. The source of the DataRowView is a DataRow.
Confused yet?
Here is an example of the manipulations to get to the real data.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim r As DataRow
Dim drv As DataRowView
For Each row As DataGridViewRow In DataGridView1.Rows
If row.DataBoundItem IsNot Nothing Then ' incase you have add new rows enabled
' 1st get the datagridviewrow's datasource
drv = CType(row.DataBoundItem, DataRowView)
' now get the drv's datarow
r = drv.Row
' now we are back at manipulating the orginal source
If r("store").ToString …
You got it.
There is nothing hard about adding a column to a datatable. The syntaX is
DataTableVariable.Columns.Add("New Column Name", GetType(String))
But if you prefer to give up on it, oh well.
What is StopWatch, because the System.Diagnostics.Stopwatch that I am thinking of does not have a name property?
http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch_properties.aspx
Or did you subclass it and add your own Name Property?
We need to be on the same page.
@TnTinMN: I have that ebook, found it very helpful. The free online version doesn't include the chapters about database programming, so he will have to buy the ebook.
@AD. LOL, you made me look again, because it did the the last time I looked. I know they supposedly have more info in their e-book, but the basic stuff is still there. In any case, it would be a good low cost reference.
or any other solution if my way is too stupid
I would not say its stupid, just not well thought out. :)
Look at what you wrote as one of your goals: " Later in that form when user clicks on the panel stopwatch must start".
To accomplish this, you will be handling the panel's "Click" event. That has nothing to do with the name that you would assign to the Stopwatch ****if it had a Name property. ****
What you do need however is a reference to the StopWatch so that you can start and stop it. All Controls have a "Tag" Property, so you could assign the StopWatch to the Panel's Tag.
However this is just plain messy and hard to maintain. I suggest that you consider creating a UserControl instead. It would house it's own timer and Click logic. Then you would just add an instance of that instead of the panel to your form.
You are on the right track by acknowledging that you need to learn how to do this versus the all to common "I want code that does this and I have no intention of ever understanding it".
This site is an excellent starting point.
Visual Basic .NET Programming for Beginners
I suggest that even if you belivee you have mastered the beginning material that you at least scan through it. The database stuff is in section 13 of 14. This fact alone should indicate to you that such coding requires an uderstanding of the fundamentals.
ADO.Net provides a consist set of tools to access data regardless of the data provider (SQLServer, MySql, OleDb, etc.) so it behooves you to read through this. I suggest you pay particular attention to the section on datasets. They can make your database coding a much more pleasant experience once learn how to crreate and use the through the IDE.
Presumably you have a table in the report and the cell expression is currently something like:
=Fields!ColumnC.Value
Use the Replace function to replace the comma,
=Replace(Fields!ColumnC.Value, ",", VBCrLf & "-")
I just realized that the file that I said I would attach did not get upload. Will try again.
I tend to use named ranges a lot when doing spreadsheet programming so I decided to attach a sample file for you to look at. I named the dropdown cell "SelectedCurrency" and the search text is "CurrencyTag" on the Data tab.
The code is:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim intersection As Range
Set intersection = Intersect([SelectedCurrency], Target)
If intersection Is Nothing Then Exit Sub
If intersection = [SelectedCurrency] Then
With ActiveSheet.Range("b:b")
Dim current As Range
Dim first As String
Set current = .Find([CurrencyTag].Value, LookIn:=xlValues)
If (Not (current Is Nothing)) Then
first = current.Address
Do
current.Offset(0, 1).NumberFormat = "[$" & [SelectedCurrency].Value & "] #,##0.00"
Set current = .FindNext(current)
Loop While (Not (current Is Nothing)) And (first <> current.Address)
End If 'Not current Is Nothing
End With 'ActiveSheet.Range("b:b")
End If 'Intersect([SelectedCurrency], Target) = [SelectedCurrency]
End Sub 'Worksheet_Change