|
Hi,
In which language are you writing the code for this? vb or vb.net? If in case of classic vb, use buttons as control array and write a single function. if in case of vb.net, write a event as follows :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button5.Click, Button4.Click, Button3.Click, Button2.Click<br />
Dim kBtn As Button<br />
kBtn = sender<br />
TextBox1.Text = kBtn.Text<br />
End Sub
Here you can use the source button's properties using kBtn variable.
Thanks,
Kiran Kumar
|
|
|
|
|
Problem:
When i fetch a list of column values from database and store them into a String One dimentional Array, it gives me exception error "Null Reference", kindly can anyone help me out, whats wrong with my code?
<br />
<br />
myProfileNames.SetValue(pfDataSet.Tables("TimerDetails").Rows(j).Item("ProfileName").ToString, j)<br />
<br />
MsgBox(myProfileNames.GetValue(j))<br />
<br />
<br />
Code:
Public Class DataAccess
Private m_strAppPath As String
Private m_connectionString As String
Public m_connectionObject As New OleDbConnection
Private dataAdapter As OleDbDataAdapter
Private pfDataSet As DataSet
// One Dimentional Array to hold String Values fetched from Database...
Public myProfileNames() As String
// Public Subroutine that will be called through an instance of this
// class.
Public Sub LoadProfiles()
Dim ProfileCount As Integer
m_strAppPath = Directory.GetCurrentDirectory
m_connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & m_strAppPath & "\TimerData.mdb"
Try
If Not (m_connectionObject.State = ConnectionState.Open) Then
m_connectionObject.ConnectionString = m_connectionString
m_connectionObject.Open()
m_ConnectionStatus = True
End If
dataAdapter = New OleDbDataAdapter("Select * from ProfileMaster", m_connectionObject)
pfDataSet = New DataSet("TimerDetails")
dataAdapter.Fill(pfDataSet, "TimerDetails")
// GET the No. of Rows that exists in Dataset
ProfileCount = pfDataSet.Tables("TimerDetails").Rows.Count
If Not (ProfileCount = 0) Then
Dim j As Integer
For j = 0 To (ProfileCount - 1)
// =========================================================================
// This is Where Problem comes Stating that Null Refrence Exception occured
// =========================================================================
myProfileNames.SetValue(pfDataSet.Tables("TimerDetails").Rows(j).Item("ProfileName").ToString, j)
MsgBox(myProfileNames.GetValue(j))
// =========================================================================
Next
End If
Catch ex As Exception
MsgBox(ex.ToString)
Finally
If m_connectionObject.State = ConnectionState.Open Then
m_connectionObject.Close()
End If
End Try
End Sub
End Class
-- modified at 14:53 Monday 28th May, 2007
:- Rashid Ali -:
|
|
|
|
|
It seems to be that the result doesn't have a field named "ProfileName". Do you have such a field in the table?
Specify the fields that you want returned in the query, instead of using *. That makes debugging easier, plus it makes the query only fetch the data that you need.
---
single minded; short sighted; long gone;
|
|
|
|
|
Friends, i got ma problem fixed
// One Dimentional Array to hold String Values fetched from Database...
Public myProfileNames() As String <-- Wrong Initialization
public myprofileNames(10) as String <-- Problem Solved:-D
But i still want to know, what if i dont know, how mnay elements my array gona contain, how to dynamically initialize array elements.
anyone there for help?
:- Rashid Ali -:
|
|
|
|
|
That's what classes like List ( or ArrayList in .NET 1.0 and 1.1 ) are for.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
Hi,
I need to disable a tabpage in a tabcontrol.
I 've tried to set the property "Enabled" to FALSE, but it doesn't shadow the text.
So I tried to set the forecolor property of the tabpage, but it doesn't work.
Finally I tried to draw each item by code as Microsoft suggests(through the drawitem event), but the result is really ugly (it losts the visual effects and the text doesn't fit in the bounds).
I cannot remove and re-add the pages for 2 reasons:
1) Each page could be enabled or disabled depending on several values in the form, so it is difficult to re-add the page in the right place
2) I LIKE the behaviour of old VB6 tabcontrol.
Can anyone help me ???
Thanx a lot.
Peace!
|
|
|
|
|
You two choices. One is to draw the tabs yourself, fixing your drawing code. I wish I had some examples to give you but I just about never use the TabControl, except in an Options dialog.
The other is to find a 3rd party TabControl that supports the visual effects you want. I don't know of any off the top of my head, well, because I just about never use the TabControl.
|
|
|
|
|
Hello
Try this that at the event of paint event of your tab page set its focus to some other or next object.
Example:
Private Sub tabpage1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles tabpage1.Paint
tabpage2.Selected = True
End Sub
Regards
Ali Raza
|
|
|
|
|
Nice idea, the controls inside the page don't respond anymore.
This can be obtained (with grayed controls) also by setting the property enabled of the tabpage...
But doesn't resolve the problem of graying the tabpage title.
Thanks, anyway.
For other friends: the command is TabPage2.Select (is a method, not a property).
Regards,
Advansis
Peace!
|
|
|
|
|
Hello. I need to activate a Timer control from other thread, so I think I have to use the Invoke method. As Timer don't have the InvokeRequired property as buttons and other controls, how can I do that?
Regards,
Diego F.
|
|
|
|
|
You create a method on your form that sets whatever you need on the Timer control. You can check the InvokeRequired of the form instead of the Timer control. Since the form's based Timer works on the UI thread, the Form is on the same UI thread and will tell you if InvokeRequired.
You Invoke the method you write from your other thread...
|
|
|
|
|
Hello,
I am working on VB.net form based application. I am having one user conrtol on the main form with some context menu item on it. All the handlers of these context menu items are implemented in the user control.
I want to implement all these context menu items on the main Menu of the main form. Now i want to call the same handlers of the context menu from my main menu.
How should i invoke the handlers form other class?
thanks in advance.
gajesh
|
|
|
|
|
the handler in the control should be like this:
public overridable sub .....handler....
or
protected overridable sub .....handler....
and in the form u can call them like this:
public overrides sub ....handler....
...or u can make a public event in the control
...or make them all public and handle their events directly in your form
A.E.K
|
|
|
|
|
'Start Word and open the document template.
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oDoc = oWord.Documents.Add
oDoc.PageSetup.Orientation = wdOrientLandscape
oDoc.PageSetup.LeftMargin = 10
oDoc.PageSetup.RightMargin = 10
oDoc.PageSetup.TopMargin = 30
'Insert a paragraph at the beginning of the document.
Set oPara1 = oDoc.Content.Paragraphs.Add
oPara1.Range.Text = "Diamant Drilling Services Run Report"
oPara1.Range.Font.Name = "Arial Rounded MT Bold"
oPara1.Range.Font.Color = wdColorBlue
oPara1.Range.Font.Size = 28
oPara1.Range.Font.Bold = False
oPara1.Range.InsertParagraphAfter
oPara1.Range.InsertParagraphAfter
Set oPara1 = oDoc.Content.Paragraphs.Add
oPara1.Range.Text = "QDC"
oPara1.Range.Font.Name = "Arial"
oPara1.Range.Font.Color = wdColorBlue
oPara1.Range.Font.Size = 8
oPara1.Range.Font.Bold = True
Ok, there is the code that opens word, opens a new document and starts to insert some things into it. my problem begins with the last block of code. once it has written the word "QDC", how do i then write another word after it on the same line without overwriting the "QDC"
I am extracting info from a database and the recordset is going to be used to populate the document. So you will have the following senario:-
QDC TYPE NUMBER
SPH423 PDC S6L1543
the second line contains the data that is extracted from the database and has to be inserted under the relevent "column headings". there might be only one record or there might be over 200, depends on what the user has searched for.
Any ideas on how to do this guys?
|
|
|
|
|
Use the InsertAfter method. It'll move the insertion point to the end
of the insert text, ready for your next insertion. You can also use
TypeText but can't remember whether that moves the insertion point or not.
Some similar to...
Set oPara1 = oDoc.Content.Paragraphs.Add
oPara1.Selection.InsertAfter "QDC"
|
|
|
|
|
Hi! All,
I have to create CSV file using data of a table. Can anybody help me on this issue?
Thanks and Regards,
Virendra
|
|
|
|
|
You forgot to say VB6 this time. VB6 is a dead language, people will assume .NET unless you say otherwise.
Which bit can't you do ? Do you have the data from the table ? Do you know how to create a file ? If you broke this into it's three obvious parts and googled, I'm sure you'd find the help you need.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
hi i am trying to read the following xml file
<sessionrequest schemalocation="\WEB-INF\xml\schema\Application.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<requesttype>APPLICATION
<token>
<requestarguments>
<application>
<companyid>TT0010001
<requesttype>APPLICATION
<application>FUNDS.TRANSFER
<version>,BM
<function>I
<operation>PROCESS
<transactionid>NEW<compscreen>MAIN
<message>
<field>
<fieldname>TRANSACTION.TYPE
<value>AC
<field>
<fieldname>DEBIT.ACCT.NO
<value>0110000020000005
<field>
<fieldname>DEBIT.CURRENCY
<value>USD
<field>
<fieldname>DEBIT.AMOUNT
<value>78
using the following code
Dim readx As XmlReader = XmlReader.Create("C:\Documents and Settings\gurubala\Desktop\1-1.t24txn.xml")
While readx.Read
If readx.NodeType = XmlNodeType.Element Then
MsgBox(readx.Name.ToString & " : " & readx.ReadString)
End If
End While
the problem here is it reads the nodes and values but starts to skip firstnode <message><field> ... it leaves <fieldname> element and reads <value>
why this happens how to avoid this
thanks
with regards
Balagurunathan.B
|
|
|
|
|
<SessionRequest schemaLocation="\WEB-INF\xml\schema\Application.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<requestType>APPLICATION</requestType>
<token></token>
<requestArguments>
<Application>
<companyId>TT0010001</companyId>
<requestType>APPLICATION</requestType>
<application>FUNDS.TRANSFER</application>
<version>,BM</version>
<Function>I</Function>
<Operation>PROCESS</Operation>
<transactionId>NEW</transactionId>
<compScreen>MAIN</compScreen>
<message>
<field>
<fieldName>TRANSACTION.TYPE</fieldName>
<value>AC</value>
</field>
<field>
<fieldName>DEBIT.ACCT.NO</fieldName>
<value>0110000020000005</value>
</field>
<field>
<fieldName>DEBIT.CURRENCY</fieldName>
<value>USD</value>
</field>
<field>
<fieldName>DEBIT.AMOUNT</fieldName>
<value>78</value>
</field>
<field>
<fieldName>DEBIT.VALUE.DATE</fieldName>
<value>20061005</value>
</field>
<field>
<fieldName>CREDIT.CURRENCY</fieldName>
<value>USD</value>
</field>
<field>
<fieldName>CREDIT.VALUE.DATE</fieldName>
<value>20061005</value>
</field>
<field>
<fieldName>CREDIT.ACCT.NO</fieldName>
<value>0110000020000017</value>
</field>
<field>
<fieldName>CHARGES.ACCT.NO</fieldName>
<value>0110000020000005</value>
</field>
</message>
</Application>
</requestArguments>
</SessionRequest>
the problem here is it reads the nodes and values but starts to skip <message>---> <field>`s firstnode ... it leaves <fieldname> element and only reads <value>
why this happens how to avoid this
with regards
Balagurunathan.B
|
|
|
|
|
Hi friends,
I am using VB6 at front end and SQL/SERVER 2005 on back end. Now i need to save pictures (in jpeg or bmp) in SQL database. And i have to display it on front end when it needs. I saved one image into database into a table field of type 'image'. It was saved. Is this the correct way to save picture in database?. Then how can I display this file in VB6.
by Dileeeeeeeeeeeeeeep.
|
|
|
|
|
How I can Add Templates Column at Run Time in the .aspx Page in VB.NET
yogesh
|
|
|
|
|
You can't, the aspx is processed before the code behind. Your best bet is probably a repeater, which means you have full control over what is rendered, and can better change it at runtime.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
Hi all
I have a game where i input winning items each with a number and picture. I enter only winning numbers in xml file so when any one plays the game, he/she only wins if winning number is entered. I dont have a ratio for winning items. What i want is to apply a random ratio for winning items.
Forexample out of 100% wins i want the wins to be as follows:
20% item1
30% item2
25% item3
25% item4
please note that in the game i can add as many items as i want.
Any ideas and thanks
|
|
|
|
|
Set up your percentage, then use a random number generator. In the example above, get a number between 1 and 100. 1-20 is item1, 21-50 is item2, 51-75 is item3, 76-100 is item4.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
Christian Iam still confused about setting up items. The case is that i dont have a fixed number of items to set up percentages, the items may vary from one time to another. If this is the case how it is this doable?
Lets suppose i fixed my winning item number to 4 items with percentages (40,30,20,10)and i used the random function
Dim RandomNumber1 As Integer
RandomNumber1 = RandomClass.Next(0, 40)
Dim RandomNumber2 As Integer
RandomNumber2 = RandomClass.Next(41, 70)
Dim RandomNumber3 As Integer
RandomNumber3 = RandomClass.Next(71, 90)
Dim RandomNumber4 As Integer
RandomNumber4 = RandomClass.Next(91, 100)
Then what?
Then only if i chosed a number between 91 & 100 i win an item4 and so on, which is not my case. I want a ratio of (40,30,20,10) of the four existing items and a ratio of (35,25,15,15,10) of my five items and so on.
Any ideas and thanks
|
|
|
|