|
Hi. How do I change the title bar heading in a form dynamically in code?
|
|
|
|
|
use below statement in the code
form1.text=" Title Here!"
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
Hi. thanks.... I had to use me.text but thanks for the help.
|
|
|
|
|
I have a textfile which has lots of records.I want to open the text file in excel.I used the codings
below.What is the problem is all the columns in the textfile seems to be in the same column of
excel.
for example
i have records in text file as follows
name location Phno
lily chennai 234567
all the three columns are in the same column of excel.
Codings used
===========
Private Sub OpenTextFile()
Dim oExcel As New Excel.Application
oExcel = CreateObject("Excel.application")
oExcel.Visible = True
oExcel.Workbooks.Open("C:\sample\test.txt")
End Sub
|
|
|
|
|
Seems reasonable to me. Excel treats each line of text as cell.
Opening the file programatically does not invoke the import wizard you are probably used to. You will need to parse each line yourself if you want it split to discreet cells
|
|
|
|
|
There is an option in excel to set tab delimiters but i dont know how to set in codings.If anybody know how to do it pls help me.
modified on Wednesday, March 19, 2008 4:28 AM
|
|
|
|
|
AFAIK you have to do this manually during the load. I do not know if you can invoke the Excel tools (they need user interaction) when processing from code.
Your could use split and write each node to a cell manually
|
|
|
|
|
|
Hi.. I have a form that is accessed from a previous form by clicking either of 2 buttons. If for example button1 on form 1 is clicked it accesses a form2 with one set of details. If button 2 on form1 is clicked it accesses form2 but with a different set of details. I need to determine which button was clicked on form 1 so I can load the correct data on form 2. Please Assist
|
|
|
|
|
When you instantiate the form you can pass the button id or a value for each button to the sub new
in the calling form
oFrm = New frmPFElement(iID)
Constructor in the called form
Sub New(ByVal iID As Integer)<br />
<br />
' This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
<br />
' Add any initialization after the InitializeComponent() call.<br />
mvID = iID<br />
End Sub
|
|
|
|
|
I'll try that thanks.
|
|
|
|
|
Just set the click event for both buttons then do a select case on the sender object of the event like below:
<br />
private sub form_Click(ByVal send as System.Object, ByVal e as System.EventArgs)Handles form1Btn.Click, form2Btn.Click<br />
Select Case sender.name<br />
Case "form1"<br />
'do something here<br />
Case "form2"<br />
'do something else<br />
End Select<br />
End Sub<br />
That should do it. I did this for an airplane seating chart. Worked great. Each seat was really a button and once it was taken I put a big red X on it to show that is was not avaliable.
Tom
Tom Wright
tawright915@gmail.com
|
|
|
|
|
My table has 4 fields that Name, Age, Date and Town. Data can add and delete. Data from Date field are displayed onto the ComboBox by DISTINCT SQL keyword. I wanna retrieve the data from Name, Age and Town by choosing a data from ComboBox that contains date data. I will display my data onto a DataGridView. When I run my project no data display noto the DataGridView. But I get for 18/3/08, error format 12:00:00AM is displayed in Message box and for other date I get correct format.
My code is following...
Private Sub cbbDate_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbbDate.SelectedIndexChanged
On Error Resume Next
Dim dt As Date
cbbDate.Text = cbbDate.SelectedItem
If Not cbbDate.Text = "All Date" Then
dt = CDate(cbbDate.SelectedItem).ToString("M,d,yyyy")
MsgBox(dt)
DisplayReport("SELECT * FROM tblSave WHERE Date=" & dt & " ORDER BY Name ASC")
Else
ShowAll()
End If
Date Field Format in the table is 'Short Date'. ( month, day, year)
Date format from ComboBox is ( day, month, year).
|
|
|
|
|
phowarso wrote: But I get for 18/3/08, error format
phowarso wrote: Date Field Format in the table is 'Short Date'. ( month, day, year)
Date format from ComboBox is ( day, month, year).
Well, that's obviously the issue then.
phowarso wrote: DisplayReport("SELECT * FROM tblSave WHERE Date=" & dt & " ORDER BY Name ASC")
Don't do this. Parameterise your query, then this sort of thing will take care of itself.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am trying to put some info from the database and datatable into a data grid and I get an error on the phone number fields when trying to display the info in the dataGrid control.
Here is the error I get.
It says it can't store the info in the column. The type is Int 32, expecting Int32.
In the database in this column I am using a bigint in sql server express 2005.
Here is my code.
Dim dt As New DataTable()
Dim dr As DataRow
For Each row As DataRow In dtStud.Rows
dr = dt.NewRow()
dr(0) = row("stud_name")
dr(1) = row("stud_par_name")
dr(2) = row("stud_id")
' get student instruments
Call studentInstruments(Convert.ToInt32(row("stud_id")))
' create counter
Dim intCount As Integer = 1
For Each row2 As DataRow In dtStudInst.Rows
If intCount = 1 Then
strInst = Convert.ToString(row2("less_instrument"))
Else
strInst += ", " & Convert.ToString(row("less_instrument"))
End If
Next
dr(3) = row("stud_phone")
dr(4) = row("stud_cell")
dr(5) = strInst
dt.Rows.Add(dr)
Next
Can anyone tell me why it expects int32 when I am using a Long for the data table column.
The error says the following:
Value was either too small or large for an int32. Couldn't store <9098791232>in stud_phone column. Expected type is Int32.
stud_phone is the name of the database field. I get this error on program start up which means it is in sub loadStudentList().
Do you thinkitmight help to convert the vlue from the database to a string?
|
|
|
|
|
I would think you would always store a phone number as string (makes this problem go away) and caters for spaces, - etc
You will need to change it at the table definition, always try and avoid format changes during processing
|
|
|
|
|
The code you posted doesn't create any columns in this new DataTable, so I'm assuming you left it out. What's the column type you created??
You also shouldn't be storing phone numbers as a number. They should be stored as a string.
|
|
|
|
|
Here are the columns. I think I can solvemy problems by changing my phone and cell to strings. I did leavethe collumn names out.
|
|
|
|
|
how do I format a phone number on output for display in a dataGrid? Lets say I want it like this.
(909)554-2574
|
|
|
|
|
I have a student combo box that when a students name is selected then it fills the student lessons combo box with the current lessons that the student is taking. The first time that you select a student it fills the lesson combo box with the lessons, but when you select a different student then the lessons combo box displays the following error in the combo box.
System.Data.DataRow
I also get this error when the program starts up.
Unable to cast object of type system.data.datarowview to type System.IConvertible.
|
|
|
|
|
check for typo's when setting the properties, this will cause the combo to display system.data.datarow
|
|
|
|
|
How do I display the time only and not the date.
I wrote a query that displays the time only, but when I try to display it in a combo box along with the day, today's date also is displayed in the combo box. I tried converting the datetime from sql to varchar and I got the time only. I also tried converting the varchar to string instead of date time in vb.net. I still get today's date.
Here is my code.
<code>' declare data table
Dim dt As New DataTable()
Dim dr As DataRow
dt.Columns.Add(New DataColumn("lessonTime", GetType(String)))
dt.Columns.Add(New DataColumn("lessonID", GetType(String)))
dr(0) = " " & arrWeekDays(Convert.ToInt32(row("less_day")) - 1) & " " & Convert.ToString(row("less_time")) </code>
Here is my query.
<code>SELECT less_id, stud_id, CONVERT(varchar, less_time, 108) AS less_time, less_day
FROM tbl_lessons
WHERE (less_status = 1) AND (stud_id = @Param1)</code>
|
|
|
|
|
Work with the date object. Get the date value from SQL as a datetime field and display less_time.toshorttimestring. If you are not happy with the format then fiddle with the format, not the data.
|
|
|
|
|
I am building an extended webbrowser which I want to support Optical Zooming as implemented in IE7. The control base uses the VS 2005 webbrowser native control with IOleCommandTarget COM interface implemented. Despite following MSDN docs on this it would appear that marshaling the pavIn and pavOut of the IOleCommandTarget.Exec does not correctly handle .Net objects for passing the zoom level. Based on several docs I have reviewed it would appear that the COM object is expecting a VARIANTARG pointer. My question is this, is there a good example of this implement in C# or VB that correctly marshals the data to the COM Interface? The follow is the COM iterface and code that I am implementing:
<br />
' Interop - IOleCommandTarget (See MSDN - <a href="">http://support.microsoft.com/?kbid=311288</a>)<br />
<comimport(), guid(="b722bccb-4e68-101b-a2bc-00aa00404770" ),="" _<br="" mode="hold" /> InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _<br />
Public Interface IOleCommandTarget<br />
Sub QueryStatus(ByRef pguidCmdGroup As Guid, ByVal cCmds As UInt32, _<br />
<marshalas(unmanagedtype.lparray, sizeparamindex:="1)"> ByVal prgCmds As OLECMD, _<br />
ByRef pCmdText As OLECMDTEXT)<br />
<br />
Sub Exec(ByRef pguidCmdGroup As Guid, ByVal nCmdId As Long, _<br />
ByVal nCmdExecOpt As Long, ByRef pvaIn As Object, _<br />
ByRef pvaOut As Object)<br />
End Interface<br />
</marshalas(unmanagedtype.lparray,>
Below is the Zooming code:
<br />
Public Sub Zoom(ByVal Level As Integer)<br />
Dim cmdt As IOleCommandTarget<br />
Dim oOut As New Object<br />
Dim oIn As New Object<br />
Dim oIE As Object = Nothing<br />
Try<br />
If Me.Document IsNot Nothing Then<br />
cmdt = CType(Me.Document.DomDocument, IOleCommandTarget)<br />
If Level < 10 Then<br />
Level = 10<br />
ElseIf Level > 1000 Then<br />
Level = 1000<br />
End If<br />
oIn = Level<br />
cmdt.Exec(CmdGUID, OLECMDID.OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, oIn, oOut)<br />
End If<br />
Catch ex As Exception<br />
Throw New Exception(ex.Message.ToString, ex.InnerException)<br />
Finally<br />
cmdt = Nothing<br />
End Try<br />
End Sub<br />
Any help with marshaling the VARIANTARGs of the Exec method would much appreciated!
Thanks in advance!!
Paul
|
|
|
|
|
Hi All,
I have a VB.Net Windows application. I want to install it at only place that is server and give access to all the users in the network. Can anybody help me in this regard.
I am able to do it by installing on every machine but instead of this I want to install it only on one machine and give access from all the machines.
Thanks,
Aleem Mohammad.
S/W Engineer
Akebono Soft Technologies
aleem_abdul@akebonosoft.com.
|
|
|
|