|
Brandon T. H. wrote: How do you get the middle number between a chosen set of two numbers, for example, I have two numbers, 2 and 8, the number I would wanna get is 5.
Add both numbers together, divide by two.
Brandon T. H. wrote: It would also help how you would convert a decibel number and round it into the closet whole number.
Add .5 and cast to an int.
Bastard Programmer from Hell
|
|
|
|
|
Public Shared Function Average(ByVal val1 As Integer, ByVal val2 As Integer)
If (val2>val1) Then
Dim temp As Integer = val1
val1 = val2
val2 = temp
End If
While (val1>val2)
val1 = val1 - 1
val2 = val2 + 1
End While
Return val1
End Function
alternatively, (val1+val2)\2
|
|
|
|
|
nice answer.. both the alternatives provided..
|
|
|
|
|
In my Project I am trying to Open Folders, I listview the startup items, and you can right click and go to the item folder location. For this code, the users appdata folder works fine. the path
C:\ProgramData\Microsoft\Windows\Start Menu\Program\Startup" Doesnt open up to the right location. It just opens up the C:\user\username\ folder instead.
If anybody knows how to open this folder it would be greatly appreciated. I am using VB 2010.
For a = 0 To (ListViewLogon.SelectedItems.Count - 1)
Dim MyKey = ListViewLogon.SelectedItems.Item(a).SubItems.Item(4).Text
Dim GroupFolderStartUpItems = ("C:\ProgramData\Microsoft\Windows\Start Menu\Program\Startup")
Dim Group2FolderStartUpItems = ("C:\Users\" & Environment.UserName & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup")
If MyKey = GroupFolderStartUpItems Then
Dim sPathspec = "C:\ProgramData\Microsoft\Windows\Start Menu\Program\Startup"
WshShell.run("explorer /e" & sPathspec, 1, False)
ElseIf MyKey = "C:\Users\" & Environment.UserName & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" Then
Shell("explorer " & Group2FolderStartUpItems, vbNormalFocus)
End If
Next
|
|
|
|
|
If you are running Windows 7 or Vista, UAC will not allow you to open the ProgramData folder.
As a result, you will not be able to access it. Running your program as administrator should allow you to read the folder.
|
|
|
|
|
The Program does run as Administrator.
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
That should be correct? Is what My manifest settings is at. unless uiAccess should be true. but Its always been this way, and when I start the program. Prompts to run under Administrator access and then starts it. Could there be something else wrong?
|
|
|
|
|
You're missing an "s" in your path; copy the one below into your explorer and you'll see the difference;
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
Also take note that explorer translates those path's into the local language, and that you can still access them over their English counterparts.
Bastard Programmer from Hell
|
|
|
|
|
Wow silly me, lol Dumb typo all along. Thank You.
|
|
|
|
|
Your typo, as well as all the problems you might have when moving your app to another Windows version, would not happen if you were to use the proper mechanism, see CommonStartup in this article[^].
|
|
|
|
|
Good day,I'm trying to deploy my VB.NET application. I decide to use installshield. Everything is fine now. I can install the app and run with no error but there's a weird thing's happening. Even I run my app and things like editing my database or copying files to install directory, nothing is changed when I look at the install directory.Database is empty and no files copied. But if I open the application again, all the changes are still there. Even I uninstall and re-install, the changes is still there.What's more weirder is this doesn't happen if I install it in XP.
|
|
|
|
|
Have the app display it's connectionstring on startup. My guess would be that they're pointing to different places.
Bastard Programmer from Hell
|
|
|
|
|
You realize that everything under Program Files is ReadOnly for normal users on Win Vista and 7? If you deployed your database files to somewhere under Program Files, they wont work because you need Write permissions to the files. Put them somewhere User friendly, like CommonAppData.
|
|
|
|
|
how to delete data from colum in datagridview
i want a clum empty
|
|
|
|
|
In a bound dataview? What have you tried?
FWIW, the documentation on the DataGridView can be found here[^]
Bastard Programmer from Hell
|
|
|
|
|
To clear data from each cell of a column of DataGridView, there is no method in DataGridViewColumn class. A method like the following can be used to clear all the cells of a column
Public Sub ClearColumn(column As DataGridViewColumn)
For Each row As DataGridViewRow In column.DataGridView.Rows
row.Cells(column.Index).Value = Nothing
Next
End Sub
|
|
|
|
|
In the RowDataBoundEvent , set the value of that cell to empty.
potected void grid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drView = (DataRowView)e.Row.DataItem;
DataRow drRow = drView.Row;
e.Row.Cells[7].Value = string.empty;
}
}
|
|
|
|
|
|
Your php code retrieves the "full" URL for the song id of 2472. Then it sends a "307 Temporary Redirect" message including the full URL to the client, which in turn will then contact the other server with that URL.
|
|
|
|
|
Hi everyone,
I have a textbox which holds numbers like e.g., xxxxxx
I wonder how to change that value entered by the user to xx-xx-xx. I'm trying several regular expressions like: OpNumbers.Replace(OpNumbers, "^(\d{6}|(\d{2}-\d{2}-\{2}))$") and also :
Format(lblOPReferenceNumber.Text.Trim, "## - ## - ##").
I'm not getting the output that need it. I'm pretty sure that I might be doing something wrong at some point.
Thank you for you help.
Venecos
|
|
|
|
|
Do you need leading zeros? Then you must use "0" instead of "#".
Dim number as int = int.Parse(textbox1.Text)
Dim result as string = number.ToString("00 - 00 - 00")
Dim result2 as string = number.ToString("## - ## - ##")
|
|
|
|
|
Alternatively, if you want to show the user the fomatted text, the MaskedTextBox control with
Mask property set as below may be used
MaskTextBox1.Mask = "00 - 00 - 00"
maskedTextBox1.TextMaskFormat = MaskFormat.IncludePromptAndLiterals
string maskedText = maskedTextBox1.Text
maskedText = maskedText.Replace("_","0")
The mask characters are explained here
http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.mask.aspx[^]
|
|
|
|
|
i want to create 2 combobox
st combobox = country
nd combobox = district/region
st combobox is the country combobox. when i choose one country , the nd combobox will change / auto populate all the region based on the selected country .
all the data is populate from access database
. im new to VB . appreciate ur help
|
|
|
|
|
A combobox has an event for the change of a selection, e.g. SelectionChanged or SelectedIndexChanged . In the corresponding event handler, get the SelectedItem of the combobox. Caution: it might be "Nothing". If it is not Nothing, query your database to get the regions. Make the regions combobox empty (e.g. comboregions.Items.Clear() ), and fill the new data into it. You could then set the SelectedIndex to 0 to preselect the first item in the combobox.
|
|
|
|
|
The solution given by Bernhard Hiller works fine.
Another option is in the DataSet designer or programmatically, create a relation between Country and Region DataTables like
Relation Name: CountryRegion
Parent Table: Country, primary key: CountryID
Child Table: Region, Foreign key: CountryID
Dim CountryBindingSource As New BindingSource(DataSet1, "Country")
Dim RegionBindingSource As New BindingSource(CountryBindingSource, "CountryRegion")
comboBox1.DataSource = CountryBindingSource
comboBox1.DisplayMember = "Country"
comboBox1.ValueMember = "CountryID"
comboBox2.DataSource = RegionBindingSource
comboBox2.DisplayMember = "Region"
comboBox2.ValueMember = "RegionID"
|
|
|
|
|
I have this assignment but I'm not getting any ideas. I have to create a program which sort people into a specified number of groups. I need help.
|
|
|
|