|
Thanks for your response.
This is pretty much what I'm looking for, but I don't know how to "build" the solution in Visual Studio 2005: 2 or 3 projects, how to compile, how to make reference to shared components, what namespace to use, etc, ...
|
|
|
|
|
Are you familiar with Visual Studio at all ?
if not, you need to read up on it, and start with a little Windows app,
"Hello World" would be fine (say 20 lines of code).
Then, inside the same solution, create a "Class library" called "Adder" pretty much
the same way; make it a class that holds a static method to add two numbers
(resulting in a DLL), which you can not "run" nor "debug" on its own.
Now go back to "hello world" and call your latest class to add two numbers; it will
fail to compile until you "add a reference" telling where "Hello World" can find the "Adder"
class, that's a reference to Adder.dll
It now should run fine; you have made two projects, one EXE one DLL.
Thats the technique; now you master this, you may start turning to your actual code
(probably in another solution).
You should read up on Visual Studio; all the above is basic information that you
will need on a dayly basis. Look around, read the Visual Help; if you dont understand
any of it, go find a book on Visual Studio; if you feel you understand, but get stuck
on a very particular issue, ask on a forum like this one.
|
|
|
|
|
I've been successfully developing in VS2005 for more than a year. I've never needed to use a DLL, I'm sorry if my question seemed too basic ...
Anyway, thank you very much your response has been very helpfull.
|
|
|
|
|
OK,
some more details:
- when you add a new project, you get a choice of different templates; use "Windows
application" for normal stuff (EXE), or "Class library" for callable code in a DLL.
- when a project wants to refer to the output of another library project (a DLL),
you must add a reference to said DLL into the Solution Pane so the calling project
knows where to find it.
- the solution has a "build order" and a "dependency graph" but these get adjusted
automatically; dont worry.
That should put you on track.
|
|
|
|
|
Hello,
I have a datagridview that has a combo box column with some items in it.
I click the item in the combo box and based on what the user has clicked on to, it should EndEdit. However, i have to click on another cell for the edit to complete.
I have tried using EndEdit thinking that it should end the edit in that combo box cell. However, the customer would like to end the edit in the cell as soon as they click an item.
I have posted the code for the selected_item event for the comb box, if this is helpful.
Private Sub dgvPendingOrders_EditingControlShowing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvPendingOrders.EditingControlShowing<br />
<br />
If TypeOf e.Control Is DataGridViewComboBoxEditingControl Then<br />
Me.dgvPendingCbo = DirectCast(e.Control, DataGridViewComboBoxEditingControl)<br />
End If<br />
End Sub<br />
<br />
Private Sub dgvPendingCbo_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvPendingCbo.SelectedIndexChanged<br />
Try<br />
'Do something here<br />
'End the edit<br />
End If<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try<br />
End Sub
Many thanks for any help,
Steve
|
|
|
|
|
You should be able to end the edit in the SelectedIndexChanged event of the ComboBox
"Okay, I give up: which is NOT a real programming language????"
Michael Bergman
|
|
|
|
|
Hi
I am just getting back into programming for a specific application in my small business. My skills are reasonable, but I'd appreciate actual code examples where possible so I can convert it. I would (for simplicity) like to use an Excel speadsheet merely as a data base for each date.
How do I have a DateTimePicker (or other similar control):
1/ Attempt to save as yyyy/mm/dd (sql format using Try)
2/ If it exists ask "yyyy/mm/dd" already exists. Do you wish..."
3/ When I choose a date, it attempts to load (Try) a file of that date "yyyy/mm/dd", other wise catches and loads a blank. (I think I can do the last bit sort of ok)
Frank
|
|
|
|
|
I'm alone in the dark! HELP!!
|
|
|
|
|
1/ To store the date in that format when entering into the database use this
'DateTime is the name of the variable (this is just for example)
DateTime = Format(DateTime,"yyyy/MM/dd")
This will store it in the format yyyy/mm/dd
2/ Query the database (use a stored procedure as inline SQL is prone to SQLInjection Attacks)
CREATE PROCEDURE DoesDateExist(@Date_Value DATETIME)
AS
SELECT
*
FROM
Table_Name
WHERE
date_value > @Date_Value
AND date_value < DATEADD(day,1,@Date_Value)
This is a simple procedure, you need to create your own according to your data structure, I was just trying to put you on the right path. As for #3, you said you can do that one so I wont answer it Last modified: 44mins after originally posted -- Inadvertanly used the LIKE keyword on a DATETIME field
"Let's face it, the average computer user has the brain of a Spider Monkey."
Bill Gates
|
|
|
|
|
You can use LIKE for a DATETIME ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You're right, I wasn't even thinking
"Well yes, it is an Integer, but it's a metrosexual Integer. For all we know, under all that hair gel it could be a Boolean."
Tom Welch
|
|
|
|
|
What I'm trying to create:
When I click on a date on the date picker, the program will automatically load the status of all tins from a file corrisponding do that date (tsyyyymmdd.xls). Moisture tins (IDed by letter & number) used on that day already will be prevented from selection. The promt to save data (from that date) should come up when a different date is selected (possibly even from the past). And so it goes.
ok, I know this syntax works for SaveAs:
'Save the sheet to c:\LabStore\TinStats folder
xlSheet.SaveAs("c:\LabStore\TinStats\myexcelsheet.xls")
how can I exchange the "myexcelsheet.xls" part for something like "ts20070720.xls"? Being the example date in this instance for 20/07/2007 (Sorry guys Australian Format
The rest of the program is simple physics which I have no trouble with, but this is melting my brain!
|
|
|
|
|
xlSheet.SaveAs("c:\LabStore\TinStats\ts" & format(today(),"yyyyMMdd")& ".xls")
|
|
|
|
|
Thank you Richard, you're a champion!!!
|
|
|
|
|
I'm nearly there!
The today's date works well, but now...
How do I make it save as the date selected (if infact different from the current date such as 2 or 3 days ago as selected by mouse) from the MonthCalendar control?
I've started by declaring,
Public dateChosen As DateFormat
but don't know how to fill "dateChosen" with the (yyyyMMdd) format, so as to insert it in place of the "today" example you gave me earlier.
I know this is all pretty basic stuff, but I'm having a devil of a time trying to find the info anywhere.
Thanks
Rod
|
|
|
|
|
I think the line of code you are looking for is this:
strFilename = "C:\myPath\ts" & Format(Me.MonthCalendar1.SelectionStart, "yyyyMMdd")
Try this this though - in case file exists already...
Dim strFilename As String
Dim strTempFilename As String
Dim i As Integer = 0
strFilename = "C:\myPath\ts" & Format(Me.MonthCalendar1.SelectionStart, "yyyyMMdd")
strTempFilename = strFilename
'Warning if file already Exists
If IO.File.Exists(strTempFilename & ".xls") Then
MessageBox.Show("File already Exists - Allocating a new Filename...")
End If
'If the file exists, then create a new filename, by appending _00, _01 etc
Do While IO.File.Exists(strTempFilename & ".xls")
strTempFilename = strFilename & "_" & i.ToString.PadLeft(2, "0"c)
i += 1
Loop
'Now Save the file
'Excel.SaveAs(strTempFilename & ".xls")
MessageBox.Show("File saved as: " & strTempFilename)
|
|
|
|
|
I have been studying and searching all day and found code similar to my needs but nothing quite fitting. I was experimenting with combinations but pretty much flying blind.
You have been so helpful mate, I don't know the words to thank you!!
Frank
|
|
|
|
|
Hi,
i want to make an html editor in vb.net.
Do anyone knows the reference for my project?
thanx
|
|
|
|
|
First build a simple notepad which opens your html file and save with changes. Then add some patter matching[^] stuff.
--------------------------------
txtSignature
|
|
|
|
|
Hi,
If you need a simple Editor you could use a textbox control (MultiLine=True, Scrollbars=Both), for colored/advanced look, you could use the RichTextBox control, building an Intellisense Engine will require you extra effort, instead you could add a set of controls (menuitems/buttons) which allow users to click on them and select from a pop-up windows the type of tag/value to insert and here you can add some validation from your side. In addition You can use the WebBrowser control to add the feature of WYSIWYG, you could also host the Editor and Viewer (WebControl) on a TabControl. Also you could use the XHTML format and use the XML rules to validate the formatting (Well-fomatted XML Document)
Hope this helps
|
|
|
|
|
I am trying to update the Employees tbl in the northwind db. I want to use code behind to do it, to better understand databinding and how ds's and da's work. I am having an issue actually posting th edata back to the db.
I am using a detailsView to display the information on my page, I am also pulling the infor for the dv from a query string, here is my pageLoad code for my details page:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim connStr As String = ConfigurationManager.ConnectionStrings("NWConnectionString").ToString()
' Create DB Connection
Dim conn As New SqlConnection(connStr)
'Create DS
Dim ds As New DataSet
'Read EmployeeID from Default.aspx
Dim sEmployeeId As String = Request.QueryString("EmployeeID")
'Create DA
Dim da As New SqlDataAdapter("SELECT * FROM Employees WHERE [EmployeeID] = " & sEmployeeId, conn)
'Open Conn to DB
conn.Open()
'Fill DA with tbl
da.Fill(ds, "Employees")
'Set DataSource to DataSet
dvDetails.DataSource = ds
'Bind DV to ds
dvDetails.DataBind()
'Close DB Connection
conn.Close()
End If
End Sub
I will post the rest of the code in my next post, to keep the post a little shorter....
|
|
|
|
|
Here is the update logic that I have written:
Protected Sub update_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles update.Click
Dim connStr As String = ConfigurationManager.ConnectionStrings("NWConnectionString").ToString()
' Create DB Connection
Dim conn As New SqlConnection(connStr)
'Create Select Statement
Dim strSql As String = "Select * From Employees"
'Create Sql Update Statement
Dim upSql As String = "UPDATE Employees SET LastName=@LastName, FirstName=@FirstName, Title=@Title, Address=@Address," & _
"City=@City, Region=@Region, PostalCode=@PostalCode, HireDate=@HireDate Where EmployeeID=@EmployeeID"
Try
'Create DataAdapter
Dim da As New SqlDataAdapter
da.SelectCommand = New SqlCommand(strSql, conn)
'Create and Fill DataAdapter
Dim ds As New DataSet
da.Fill(ds, "Employees")
'Get the DataTable
Dim dt As DataTable = ds.Tables("Employees")
'Modify the Rows
dt.Rows(0)("LastName") = "@LastName"
dt.Rows(0)("FirstName") = "@FirstName"
dt.Rows(0)("Title") = "@Title"
dt.Rows(0)("Address") = "@Address"
dt.Rows(0)("City") = "@City"
dt.Rows(0)("Region") = "@Region"
dt.Rows(0)("PostalCode") = "@PostalCode"
dt.Rows(0)("HireDate") = "@HireDate"
'Update Employees Table
'Create Command
Dim upCmd As New SqlCommand(upSql, conn)
'Map Parameters
upCmd.Parameters.Add("@LastName", SqlDbType.VarChar, 20, "LastName")
upCmd.Parameters.Add("@FirstName", SqlDbType.VarChar, 10, "FirstName")
upCmd.Parameters.Add("@Title", SqlDbType.VarChar, 30, "Title")
upCmd.Parameters.Add("@Address", SqlDbType.VarChar, 60, "Address")
upCmd.Parameters.Add("@City", SqlDbType.VarChar, 15, "City")
upCmd.Parameters.Add("@Region", SqlDbType.VarChar, 15, "Region")
upCmd.Parameters.Add("@PostalCode", SqlDbType.VarChar, 10, "PostalCode")
upCmd.Parameters.Add("@HireDate", SqlDbType.DateTime, 8, "HireDate")
'Map EmployeeID Parameter
Dim idParam As SqlParameter = upCmd.Parameters.Add("@EmployeeID", SqlDbType.Int, 4, "EmployeeID")
idParam.SourceVersion = DataRowVersion.Original
'Open the connection
conn.Open()
'Update Employees Table
da.UpdateCommand = upCmd
ds.AcceptChanges()
da.Update(ds, "Employees")
Catch ex As Exception
'Display Error
Console.WriteLine("Error: " & ex.ToString())
Finally
'Close Connection
conn.Close()
'Redirect to Home
Response.Redirect("~/Default.aspx")
End Try
End Sub
I know it has something to do with passing the data back to the ds, but I am not sure what I am missing. Also, am I referencing an unknown row properly in the 'Modify Rows' section?
Any and all help is appreciated. I think I am close, but not sure what I am missing.
Stupid1
|
|
|
|
|
TextBox1.Text = Replace(SplitTextLineContent, SplitTextLineContent.Substring(SplitTextLineConten t.ToString().IndexOf("V"), SplitTextLineContent.ToString().IndexOf(vbNewLine) ), "")
SplitTextLineContent contains many lines of text.
I would like to replace those char or text that start with "V" until end of the line (vbNewLine) with " ". In other words, take out those text after "V" until the end of the line and replace with blank " ". But the coding above is incorrect. Pls help.
|
|
|
|
|
Hi,
first of all you will not win a special prize for trying to do all your stuff in a single
line of code; instead you will loose points for unintelligible code.
What you need is locate the start point of your string to be replaced (you have that already);
from there, find the next newline (use an overload of IndexOf that lets you specify a starting point);
then perform the necessary replacement, which requires two String.Substring calls (the
Replace method might "hit" several times!).
And you need to handle the special case when no newline is found too.
so in the end that will take about 5 lines of simple code.
|
|
|
|
|
Hi,
whether can show me the example? I don't understand
use an overload of IndexOf that lets you specify a starting point);
then perform the necessary replacement, which requires two String.Substring calls (the
Replace method might "hit" several times!
Your prompt reply will be kindly appreciated. Thanks
|
|
|
|
|