|
|
Can I overload the System.DateTimeOffset class so that I can write either:
dim d = now.date 'existing
or
dim p = now.mynewproperty 'overloaded by me
Thanks
|
|
|
|
|
You can derive a class from any class you like. I believe you can also use extension methods to add a method to a class, but I've never done that.
To add - you'd need to override the Now property to return an instance of your new class, if you wanted to add a property to the Now property.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Please if anyone could offer me help on this, I need to know how to invoke a dopostback in the web browser control in visual basic. My idea is that I want to capture data from a website (authorized) that is using asp.net server. The website has a dropdownlist that postbacks according to the value chosen and shows the value (that i need to capture).
If anyone could Help , I would appreciate it
THanks
|
|
|
|
|
Hi everyone,
I have a datagridview with 3 columns "Name", "Age", "salary".
While displaying in datagridview, I hide the "Age" column and display only the two column using this code:
DataGridsearch.Columns("Age").Visible = False
Now I have written one code for ClickRow event of datagridview, in which when user clicks any row, the content of the cells get displayed into the respective textboxes for "Name" and "Salary". The code is like this:
Dim row_click As Integer
row_click = DataGridView.CurrentRow.Index
name.Text = DataGridView.Item(0, row_click).Value
salary.Text = DataGridView.Item(2, row_click).Value
Now, i am able to display both "Name" and "Salary" in its respective textboxes, from datagridview, but not able to display the "Age" in its textbox "age.Text".
Can anyone tell me how to do this, since I have already hide the "Age" column while displaying in datagridview?
|
|
|
|
|
You need to use VB equivalent of this C# code. DataGridView.Rows[RowIndex].Cells[ColIndex].Value.ToString()
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Hi,
I didn't get how to implement this as I have hidden 1 column. Can i get some help on this more?
|
|
|
|
|
I wrote an application in VB 2003 which used the "SqlClient.SqlConnection". I used standard connection code;
ConnectionString="workstation id=MySys;packet size=4096;data source=MySQL;User ID=RP;PASSWORD=RP;initial catalog=Inventory"
cnData.ConnectionString = ConnectionString
Try
cnData.Open()
Catch
MsgBox("Data Source could not be opened.")
Exit Sub
End Try
and it worked fine. I opened it in vb 2008 and it performed the conversion without any reported errors, but it will no longer connect?
MySys is a separate Development system and MySQL is another system on my LAN running SQL Server 2000.
I have been to www.connectionstrings.com[^] but after trying numerous things, nothing helped. Any ideas?
modified on Saturday, September 26, 2009 1:20 AM
|
|
|
|
|
Found the answer, it appears I had to add the Network Library to get this to work!
ConnectionString=Workstation ID=MySys;packet size=4096;Data Source=MySQL;User ID=RP;Password=rp;Initial Catalog=Inventory;Network Library=dbnmpntw
That must have been assumed in VB 2003?
|
|
|
|
|
Hi,
Can anyone give me a simple code to import a datagrid to excel?
I look over the web, it appears that I cannot find a suitable code for my application.
I am using visual studio 2005..
one problem that I encountered from some of the codes that I found is that I cannot use this import syntax(Imports Excel = Microsoft.Office.Interop.Excel) for excel.
Thanks for your help with this question.
|
|
|
|
|
Since you have a datagrid, you must have it bound to a dataset. Right?
You could instantiate Execl in your VB program like this:
Imports Microsoft.Office.Interop
Dim ExcelApp As New Excel.Application
Here are some additional code snipets ...
Dim ExcelBookTmp, ExcelBookMaster As Excel.Workbook
Dim ExcelSheetTmp, ExcelSheetMaster As Excel.Worksheet
ExcelApp.Visible = True
ExcelApp.Workbooks.Add()
ExcelBookMaster = ExcelApp.Workbooks(1)
ExcelSheetMaster = ExcelBookMaster.Worksheets(1)
ExcelSheetMaster.Cells(1, 1) = "Hello World"
ExcelApp.Workbooks.Open(Me.TextBox1.Text, , True)
You could then loop around your dataset and populate the Excel worksheet.
Cool stuff.
|
|
|
|
|
Hi,
thanks for replying. But when I instantiated (Imports Microsoft.Office.Interop) excel. I got namespace or type in the imports"Imports Microsoft.Office.Interop" doesn't contain any public member or cannot be found.
Guide me on this.
Thanks
|
|
|
|
|
In VS2005, under the Project Menu, click Add Reference.
On the "COM" tab of that window, verify that Microsoft Office 11.0 or 12.0 Object Library is listed.
Question: Is MS-Office installed on the machine you are trying to develop this?
|
|
|
|
|
Hi David,
Thanks but the reference is there and ms office is installed.
Await for more suggestions.
Thanks alot
|
|
|
|
|
The most reliable and flexible solution is to use xml.
First create an excel file in MS Excel. Format it according to what you would like the end result to look like. Save the file as xml.
Open the xml file with visual studio, and see what it looks like. Then use a string or streamwriter or whatever, to create a copy of the header part of your file. Then loop through your datagrid, dataset, or datatable, and add each row to the rows bit of the file.
If necessary finish off with any footer part of the file, and then save the whole thing as whateverfilename.xls
And presto! you can create an xls file without needing ms office installed on the machine that your app is running on, and that will work in any Excel version, not just the version that happens to be installed on the development machine.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Thanks but I know nothing in xml.
|
|
|
|
|
|
Add a comment within your code with TODO: at the start and it will appear in your To Do list in Visual Studio. Very handy.
for example:
'TODO: Review this code
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
Hi everyone i need to create a match fixture in vb.net i need to write a code that enable two teams compete against each other in a match game. can someone tell me how to do this please
thanks
|
|
|
|
|
Define what you mean by "fixture" and what a "match" consists of.
|
|
|
|
|
He defined all that to you the LAST time he asked you to do his homework for him.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Yep, and it still wasn't enough to get him to think about the solutions to each little problem.
|
|
|
|
|
Look here. You have been asking this question for days. You will still be asking it when this project is due, and you will fail. And, you deserve it. We do NOT do homework for people not even willing to make a start for themselves. If we did, it would not help you, because you'd have learned NOTHING and you would therefore be stuck on the next assignment, which would assume you knew how to do the first one. Either read your resources, talk to your teacher, or drop out of your course and get a job at McDonalds.
We're happy to help people who are trying and are stuck. We don't help people to get through courses without learning anything, because odds are, we may well end up stuck with them on our teams.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello to All,
I have two buttons button1 and button2.
in button1_Click
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error GoTo err
Groupbox3.visible = False
GroupBox1.Visible = True
cmb_barcodefont.Focus()
Exit Sub
err:
MsgBox(Err.Description, MsgBoxStyle.Information, Err.Number)
End Sub
and
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Groupbox1.visible = False
GroupBox3.Visible = True
Dim intimage As Integer
Dim barlist As LinearBarCode.Barcode = Barcode1
ReDim imageArray(ListbarcodeValue.Items.Count)
If ListbarcodeValue.Items.Count > 0 Then
For intimage = 0 To ListbarcodeValue.Items.Count - 1
barlist.DataToEncode = ListbarcodeValue.Items.Item(intimage)
Dim img As System.Drawing.Image = barlist.IndependentEMF
imageArray(intimage) = img
Next
Else
Image = barlist.IndependentEMF
End If
barlist = Nothing
Updowncolumn.Focus()
End Sub
at this time the error is occor
System.ArgumentException was unhandled
Message="Parameter is not valid."
Source="System.Drawing"
StackTrace:
at System.Drawing.Image.get_FrameDimensionsList()
at System.Drawing.ImageAnimator.CanAnimate(Image image)
at System.Drawing.ImageAnimator.ImageInfo..ctor(Image image)
at System.Drawing.ImageAnimator.Animate(Image image, EventHandler onFrameChangedHandler)
at System.Windows.Forms.PictureBox.Animate(Boolean animate)
at System.Windows.Forms.PictureBox.Animate()
at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.MessageBox(HandleRef hWnd, String text, String caption, Int32 type)
at System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp)
at System.Windows.Forms.MessageBox.Show(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
at Microsoft.VisualBasic.Interaction.MsgBox(Object Prompt, MsgBoxStyle Buttons, Object Title)
at Barcode_Software.Form1.Button1_Click(Object sender, EventArgs e) in E:\Barcode_Software\Barcode Software\Form1.vb:line 173
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Barcode_Software.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
If you can think then I Can.
|
|
|
|
|
Looks like your code has an error, AND you're passing invalid params to the message box. Have you considered using breakpoints to debug your code ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|