Sunday, December 11, 2011

In VB.Net - How do I offer the ability for user to change the font of any individual control?

I can place the Font Dialog on the form. But in runtime the whole form is changed when this is called. How do I allow the user to choose which button, textbox, etc they want to change?In VB.Net - How do I offer the ability for user to change the font of any individual control?
You can click the button and have the font change on that. Or you can compare the control that you want with that one the page and change the font that way. Example;

If CType(lblTime, Label).Text = ';One'; Then

...

End If



But you will have to put that through a loop...



EXAMPLE:THIS IS TO LOOP THROUGH BUTTONS



Private Sub btnListAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnListAll.Click

On Error Resume Next

'Looping through all the buttons using this code



'For Each GetButton as Control in Me.Controls

'If TypeOf GetButton Is Button then

'txtGetTest.Text %26amp;= GetButton.text %26amp; vbCrLf

'End If

'Next



'The problem is the code will NOT see the

'controls in the GroupBox's



'Reset the counter

m_ControlCount = 0

'Clear the textbox

txtGetText.Clear()

'Goto the user create sub

'Get the objects in Me( form )

ShowAll(Me)



'If code said ';ShowAll(Me.GroupBox1)';

'The oaContainer would return all the

'controls in the Groupbox ONLY



End Sub

Sub ShowAll(ByVal oaContainer As Control)

On Error Resume Next

'Get all the controls in the control area specified (Me)

For Each cntrl As Control In oaContainer.Controls

'If the current control in a button and

'the control is not blank then

If TypeOf cntrl Is Button AndAlso _

Not (cntrl.Text = Nothing) Then

'Add one(1) to the counter

m_ControlCount += 1

'Add counter and the

'control name to the nextbox

'START a new line

txtGetText.Text %26amp;= _

m_ControlCount %26amp; ';) '; %26amp; cntrl.Text %26amp; vbCrLf



End If

'Input this to show ALL the controls

'on the form

ShowAll(cntrl)

'Refresh the control

'IF Refresh() is NOT implemented

'Error will occur when user presses another button

cntrl.Refresh()

Next



End Sub

How can i monitor the ending date of the month by coding it in vb 6?

I was asked to create a program with counter that will reset to 0 when it reaches the end of the month. The purpose of the counter is to count how many print outs were made during the month, so when the month ends the counter will be back to 0 to monitor another set of print outs to be made for the succeeding months.



Can anyone give me hints on vb 6 date properties?How can i monitor the ending date of the month by coding it in vb 6?
I think this syntax will do the job:



If datepart(day, date) = 1 then



' put code to reset the counter



End if

How do I code a calculate button for a sample account in VB ?

I'm trying to code a scenario for a man who wants to know his total balance after having entered his *money at the beginning of the month, the money he earned, and the money he spent* i have all the texts boxes and labels but I'm not entirely sure how to go about coding the calculate button.



startTextBox

earnedTextBox

spentTextBox

totalTextBox (read only)

How do I code a calculate button for a sample account in VB ?
dim start as decimal = txtStart.text

dim earned as decimal = txtEarned.text

dim spent as decimal = txtSpent.text

dim total as decimal



total = start + earned - spent



txtTotal.text=total



You might want to use a label box for total instead of read-only text but it probably doesn't really matter. Label is more standard.



You should also use a try / catch feature in your input text boxes to make sure your user doesn't type in entries that break your program when they can't be converted to decimals.



Also, you used a naming convention that IMHO isn't that great. startTextBox is fine if you can remember what you called it, but that gets problematic in larger programs. Better is to do it the way I showed it, which is to start with what the object is. IE: txtStart That way you can forget the name, but just hit 'txt' in the IDE, and intelesense with bring up a list of all your declared textbox items. Makes life a lot easier down the road.



Hope that helps!

How do I manually add data from textbox to datatable using VB 2005 with MySQL?

WARNING! THIS CODE DOESN'T WORK!



currencymanager.addnew()

datatable.defaultview(currencymanager.鈥?= textbox.text



command = new mysqlcommandbuilder(dataadapter)

dataadapter.updatecommand = command.getupdatecommand

dataadapter.update(datatable)

currencymanager.endcurrentedit()



if currencymanager.count = 2, position can be 0 or 1. after calling addnew(), count = 3 position = 2. when i try to assign the value of textbox.text to its datatable column using the code above, error because datatable has no position 2.



my update code also doesn't work. but if i copy paste it after the first update code, making it redundant, my database gets updated successfully.



thanks for anyone who may correct the code.How do I manually add data from textbox to datatable using VB 2005 with MySQL?
The following code uses the dsEmployees DataSet. It locates the DataTable named Manager in the Tables collection. It then selects the first DataRow object, and changes the value of its LastName item to ';Stephens'; (the update data).



dsEmployees.Tables(';Managers';) _

.Rows(0).Item(';LastName';) = ';Stephens';



' The above statement is actually one line.

' Answers does not display it properly.

' So, I used an underscore character to break it into two lines.

' You can combine the two lines, and omit the underscore.

' In the expression to the left of the equal sign, there are no spaces.



If you want to update by using the contents of a TextBox, then simply use, i.e., TextBox1.Text for the update data.



__________-

I want to convert VB form code to Java and have downloaded a couple converters but don't know how to use them.?

I downloaded the one from Diamond Edge and the one from getobject.com. Both are .dll files and I don't know how to implement them. I have Visual Studio 5. Any tips? thanks in advance.I want to convert VB form code to Java and have downloaded a couple converters but don't know how to use them.?
dll files aren't programs.



Convert the files by rewriting every function into Java. That's the fastest and easiest way. (Assuming that you understand both VB and Java - if you don't, you can't, even with a converter program - even the best ones leave a lot for you to clean up by hand.)



But try http://www.tvobjects.com/products/Conver鈥?/a> or http://www.download.com/VB-Converter-Jav鈥?/a>
  • dry hair
  • How to write desktop application in VB.Net to send & receive SMS using GSM Modem?

    I have to write a desktop application in VB.Net to send %26amp; receive SMS using GSM Modem. The purpose of the application is to receive request for inventory status for a particular item %26amp; send the availability status to the user.How to write desktop application in VB.Net to send %26amp; receive SMS using GSM Modem?
    save urself the trouble.there r many freewares wich support GSM Modems n enable free sms.

    How can I print the data in a grid in vb?

    I need to print the data present in a grid which I load from a text fileHow can I print the data in a grid in vb?
    I am going to assume you mean VB.NET and not version 6. I have included a wonderful article below that shows you how to build an application that prints the data from a custom datagrid control. Allows you to do print preview etc and make it all fancy.



    Hope this example can help you out in the right direction.



    Enjoy!