|
Luc Pattyn wrote: did you check the type of NUD.Value?
How?
|
|
|
|
|
by reading the documentation!
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
The Value property on a NumericUpdown control is a decimal (that's what the "D" indicates). Try casting it to an integer value before you use it in the for loop.
dim i as integer
dim max as integer
max = Convert.ToInt32(numericupdown1.value)
for i = 1 to max
listbox1.item.add(i)
next
|
|
|
|
|
Thank you very much for your help. I will try this code.
|
|
|
|
|
Kanel, this one was so easy to solve, it's silly. All you had to do was click on the Value part of the code you posted and hit <F1>. It's spelled out right in the docs what the return type is.
Even easier, you didn't even have to do that. After you typed numericupdown1 and hit the period key and started to type Value , Intellisense would have popped up and shown you right there what the return type is.
Public Proprty Value() As Decimal
Gets or sets the value assigned to the spin box (also known as an up-down control).
I know we keep beating this into everyone's head around here, read the documentation!! We do it for a reason. Rule number 1 in troublshooting: Verify, verify, verify. Verify that your using the correct types. Verify that the values you are putting in and using are what the object/method expects. Verify that you know, not assume, how the object works! The only way to do that is to read any and all documentation on the object.
|
|
|
|
|
What does the code below do??
Err.Clear
Set ts = fso.OpenTextFile("C:\userlevel\userlevel_billing.txt", 1, False, -2)
If Err.number = 0 Then user_level = user_level + 1
|
|
|
|
|
This belongs in the web dev forum, really. Why on earth would anyone be an asp beginner ? asp sucks.
The fso is the file system object created via COM. It can be called anything, but it's often called that.
Without even remembering the details, it's obvious to me that this code reads the text from a text file into a variable, and if no error occurs, the variable user_level is incremented. Google is the best place to find out what those options in the function call mean, but their lack of readability is one example of why asp is hideous.
Most people create const variables to contain the flags that things like 1 and -2 represent, in a vain attempt to make ASP code readable.
Christian Graus - Microsoft MVP - C++
"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 programming a personal project, i would like about than how read a mp3 file from vb, but not only the header as i found many examples, else i would like read a mp3 file totaly to after i make others operations with him.
Thanks for help about how can know the mp3 structure, read the headers and load mp3 music section, greetings from mexico.
|
|
|
|
|
Hi. I am working on a form designer program in vb.net. The user will able to add, remove, and manipulate controls on a form.
I saw an article once about saving a form as a file (I believe it was XML), but I can't seem to find it. Can anyone help me find out how to save and load a form from a file?
Thanks,
Richard Faulkner
|
|
|
|
|
Have you done an article search here ( assuming you are meaning you saw the article here )?
"Find it your bloody self - immediately!" - Dave Kreskowiak
|
|
|
|
|
I am not sure if the article was from this site, but I have done a search and came up with no results
|
|
|
|
|
Hi,
as the title says?
But do it programmaticly, not within the designer (drag & drop)
I have created a XML file with another function, it is valid.
How to extract the XMl file and show its columns and data in a datagrid?
I have tried using a dataset, I have filled the dataset with the xml data. But I don't know how to show it in a dataGrid View.
Thank you very much in advance!
|
|
|
|
|
unix_master01 wrote: I have tried using a dataset, I have filled the dataset with the xml data. But I don't know how to show it in a dataGrid View.
MyDataSet.ReadXml(filepath)
DataGridView1.DataSource = MyDataSet
DataGridView1.DataMember = "someTableNameInDataSet"
|
|
|
|
|
Hi Friends,
Using VB.net 2003 and sqlserver 2000
Private Sub checkclick()
If CheckBox1.Checked = True Then
month1 = "January"
End If
If CheckBox2.Checked = True Then
month2 = "February"
End If
If CheckBox3.Checked = True Then
month3 = "March"
End If
If CheckBox4.Checked = True Then
month4 = "April"
End If
If CheckBox5.Checked = True Then
month5 = "May"
End If
If CheckBox6.Checked = True Then
month6 = "June"
End If
If CheckBox7.Checked = True Then
month7 = "July"
End If
If CheckBox8.Checked = True Then
month8 = "August"
End If
If CheckBox9.Checked = True Then
month9 = "September"
End If
If CheckBox10.Checked = True Then
month10 = "October"
End If
If CheckBox11.Checked = True Then
month11 = "November"
End If
If CheckBox12.Checked = True Then
month12 = "December"
End If
End Sub
Dim con As SqlConnection = New SqlConnection("workstation id='YOUR-A77D0E1DAD';packet size=4096;integrated security=SSPI;data source='.';persist security info=False;initial catalog=FORUT")
Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
checkclick()
Try
Dim DA As SqlDataAdapter = New SqlDataAdapter '("SELECT * FROM FINACIAL_REQUEST_REPORT", CON)
Dim DS As New DataSet
DA.SelectCommand = New SqlCommand
DA.SelectCommand.Connection = con
DA.SelectCommand.CommandType = CommandType.Text
con.Open()
If CheckBox13.Checked = True Then
DA.SelectCommand.CommandText = "SELECT * FROM FINACIAL_REQUEST_REPORT where YEAR1='" & NumericUpDown1.Text.Trim & "'"
Else
DA.SelectCommand.CommandText = "SELECT * FROM FINACIAL_REQUEST_REPORT where YEAR1='" & NumericUpDown1.Text.Trim & "' AND (MONTH1='" & month1 & "' or MONTH1='" & month2 & "' or MONTH1='" & month3 & "' or MONTH1='" & month4 & "' or MONTH1='" & month5 & "' or MONTH1='" & month6 & "' or MONTH1='" & month7 & "' or MONTH1='" & month8 & "' or MONTH1='" & month9 & "' or MONTH1='" & month10 & "' or MONTH1='" & month11 & "' or MONTH1='" & month12 & "')"
End If
DA.Fill(DS, "FINACIAL_REQUEST_REPORT")
con.Close()
Dim OB As New C_FINANCIAL_REQUISITION
OB.SetDataSource(DS.Tables("FINACIAL_REQUEST_REPORT"))
CrystalReportViewer1.Visible = True
CrystalReportViewer1.ReportSource = OB
Catch ex As Exception
MsgBox(ex.Message)
con.Close()
End Try
End Sub
Thanks a lot
|
|
|
|
|
Wow, there's a lof of stuff bad with this. OK.
Without doing anything to your database, which itself needs a redesign, you can build an SQL SELECT with and IN clause.
First, you don't need all the month* variables. Get rid of them.
Next, add a Tag value to each of your CheckBox's with the month name corresponding to each one. CheckBox1.Tag="'January'", CheckBox2.Tag="'Febuary'", ... (NOTE: The single quotes in those strings!)
Wire up all the CheckBox's CheckChanged events to the same handler. See the Handles clause at the end?? Add all of the CheckBox's to it.
Private Sub CheckBox_CheckChanged(blah, blah) Handles, CheckBox1.CheckChanged, CheckBox2.CheckChanged, ...
In this handler, cast the sender back to a CheckBox and get the Tag property from it. In an ArrayList collection, check to see if the Tag value is in the collection, if not, Remove it, else, Add it. A quick'n'dirty version of this would look something like:
Dim cb As CheckBox = DirectCast(sender, CheckBox)
If Not myMonthList.Contains(cb.Tag) Then
myMonthList.Add(cb.Tag)
Else
myMonthList.Remove(cb.Tag)
End If
Mind you, this code doesn't care if the checkbox is checked or not!! You might want to factor that into this code.
When you go to build the SQL query string, you'turn the collection of months, myMonthList in the above example, into a String of values seperated by commas, like this:
Dim months As String = String.Join(",", myMonthList.ToArray(GetType(String)))
You then make that list part of you SQL statement:
Dim sql As String = String.Format("SELECT * FROM Finacial_Request_Report WHERE year1='{0}' AND month1 IN ({1})", NumericUpDown1.Text, months)
You'll get a statement that looks something like this:
SELECT * FROM Financial_Request_Report WHERE year1=1980 AND month1 IN ('January','Febuary')
But, this is quick'n'dirty. A good solution would require you to redesign your database and scrap all the code you put up in your original post.
|
|
|
|
|
hii
i am able to draw a rectangle of any size , Now i want to draw small size of rectangles in big rectangle , so that user can align the controls.
And i want the big rectangle as dotted line . ( For example in vb .net show grid options ) in that they showed as dots) , but i want to show in rectangles . For example , Like Graph sheet
DVSRIRAM
|
|
|
|
|
All you have to do is draw a line from the top of the rectangle to the bottom, every so often acrossed the rectangle. Then repeat the process drawing lines across the rectangle.
You already have the position and dimensions of the rectangle. The rest is easy. Don't even think of copy'n'pasting this into your code, cause it's not real code. You actually have to write it yourself.
'Draw your rectangle, then do something like this:
For x = 0 to rectangleWidth Step spacing
DrawLine( x+rectangleLeft, 0, x+rectangleLeft, rectangleHeight )
Next
For x = 0 to rectangleHeight Step spacing
DrawLine( 0, x+rectangleTop, rectangleWidth, x+rectangleHeight )
Next
|
|
|
|
|
I have a simple vb.net app that takes a user's username and password (they have to enter it in) and it will open a program using a RunAs function. What I need to check before hand is if the credentials that I have been given have administrative rights on the workstation it is attempting to log in with. The person logging into the app may not be the same credentials that logged into the PC. If they don't have admin rights I need to keep them from logging in a presetn them a message. Does anyone have a code example of this process?
Thanks,
archangel_26
|
|
|
|
|
It's amazing what you can find if you just type in a little phrase into Google. Like trying "VB.NET check for admin[^]".
|
|
|
|
|
Yes I did already check that - I already found those examples and neither of them would work for me. I will freely admit to being a VB.net newbie. So, do you have any suggestions?
|
|
|
|
|
Neither?? That implies two. There's hundreds of them...
OK. There's a bit of a problem with checking to see if a user has admin rights. You can't just check on the local machine, and find out "OK this person is good". You actually have to ask the remote machine your connecting to if the person has admin rights. But, there's no function to do that. The best way to find out is actually attempt to do whatever it is your doing, and if it fails, then you know.
|
|
|
|
|
Maybe this is something for you, it costed me blood and tears to get it right
Copy the code below in a function, you still need to change the static values DOMAIN and USER to dynamic values
DOMAIN can be ComputerName or DomainName
USER is the user account used for to logon
Don't forget to put the following on top of your page:
Imports System.Management
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_GroupUser WHERE PartComponent = " & Chr(34) & "Win32_UserAccount.Domain=\" & Chr(34) & "DOMAIN\" & Chr(34) & ",Name=\" & Chr(34) & "USER\" & Chr(34) & Chr(34))
For Each queryObj As ManagementObject In searcher.Get()
Console.WriteLine("-----------------------------------")
Console.WriteLine("Win32_GroupUser instance")
Console.WriteLine("-----------------------------------")
Console.WriteLine("GroupComponent: {0}", queryObj("GroupComponent"))
Console.WriteLine("PartComponent: {0}", queryObj("PartComponent"))
Next
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
The result of this query is:
-----------------------------------
Win32_GroupUser instance
-----------------------------------
GroupComponent: \\NC8000\root\cimv2:Win32_Group.Domain="DOMAIN",Name="Administrators"
PartComponent: \\NC8000\root\cimv2:Win32_UserAccount.Domain="DOMAIN",Name="USER"
-----------------------------------
Win32_GroupUser instance
-----------------------------------
GroupComponent: \\NC8000\root\cimv2:Win32_Group.Domain="DOMAIN",Name="Debugger Users"
PartComponent: \\NC8000\root\cimv2:Win32_UserAccount.Domain="DOMAIN",Name="USER"
good luck
|
|
|
|
|
This is nice and all, but it only checks group membership. It doesn't check anything against the the resultant set of policies and security permissions.
|
|
|
|
|
I've found a bit of code that almost works. Here is the scenario:
A set of users will belong to a group. It is called "group1" . I am attempting to run this code to check if they belong to this group. If so - let them continue. If not, then catch the error. Here is the problem. When I (myaccount) is logged into the machine it will authenticates fine for me. It won't authenticate for someone who is a member of Group1. Even if the other user is a member of group1 and has admin rights such as "Otheraccount" does below. The workstation this is running on has this in the Administrators group:
DOMAIN\myaccount
DOMAIN\otheraccount
DOMAIN\Group1 (myaccount and otheraccount are members of this group)
I am running this code:
'***********************************************************
Dim SecurityCheck As New PrincipalPermission("DOMAIN\"& strUserName, "DOMAIN\Group1")
Dim strError As String
Try
SecurityCheck.Demand()
Catch errormessage As System.Exception
strError = errormessage.Message
If strError = "Request for principal permission failed." Then
MsgBox("You are not a local administrator. You do not have rights to access this software. If you need access, please contact your manager.")
Me.Close
Exit sub
Else
msgbox(strError)
End If
'***********************************************************
Any suggestions? I have tried this as well with the same results:
Dim SecurityCheck As New PrincipalPermission("DOMAIN\"& strUserName, "Administrators")
|
|
|
|
|
archangel_26 wrote: I've found a bit of code that almost works.
Not "almost". Actually, it'll never work.
To check the user currently running the code against the role, you have to use an IPrincipal object representing the user, not a PrincipalPermission. You created a Permission object, not a Principal object you can check roles against.
' Get the current prinicpal this thread is running under
Dim userPrincipal As IPrincipal = System.Threading.Thread.CurrentPrincipal
' Check if this principal is a member, through any number of nested groups
' and permissions, of the local Administrators group. For instance, if in
' a domain environment, a user can be a member of the Domain Admins domain
' group, which in turn can be a member of the local machines Administrators
' group. This line would return true if that user was running this code.
Dim result As Boolean = userPrincipal.IsInRole("Administrators")
|
|
|
|
|