|
Again, ActiveWorkSheet returns a WorkSheet object but you have defined
Dim xlWorkSheet1 As Excel.Worksheets
|
|
|
|
|
I have a problem in my programming class. A person gets paid daily, day one is 1 penny, day two is 2 pennies, day three is 4 pennies, day five is 8 pennies and so on doubling each day. I wrote the following code but am having an issue with out put. When I put in 1 day it tells me 2 pennies instead of 1. I am sure this is an easy fix but my brain is fried and I am overlooking it.
Here is my code:
Public Class Form1
Private Sub calculateButton_Click(sender As Object, e As EventArgs) Handles calculateButton.Click
Dim intDays As Integer
intDays = 1
Dim decPennies As Decimal
decPennies = 0.01
For intDays = 1 To cboDays.Text
decPennies = decPennies * 2
Next intDays
ansLabel.Text = decPennies.ToString("C")
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For intDays = 1 To 20
cboDays.Items.Add(intDays)
Next
End Sub
End Class
Any help would be greatly appreciated.
|
|
|
|
|
For intDays = 1 To cboDays.Text
decPennies = decPennies * 2
For ... 1 To 1 will do this once, so you get your pennies as 2. You need to rethink the loop type, maybe a better idea would be to use While ... End While[^].
|
|
|
|
|
Look at powers of 2 - also - are you tring to find the number of pennies they are paid on a particular day, or the total number of pennies they have on that day?
For intDays = 1 To cboDays.Text
decPennies = decpennies + 2^(intdays-1)
next
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Chris Quinn wrote: For intDays = 1 To cboDays.Text
decPennies = decpennies + 2^(intdays-1) next
No loop is required at all!
The total is just:
decPennies = 2^Val(cboDays.Text) - 1
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|
|
Hi today i am wondering how to disable user's from accessing or changing the windows desktop background from where only an admin can change them and i need to know how to put this code into my application so when a user clicks a button they automatically change the privileges to admin so that guests on the computer cant change the desktop background or personalize it without putting in the admins user name and password.
|
|
|
|
|
First, bad idea. Why? Because a user cannot grant more permissions to something than they themselves have.
Second, you don't need code for this at all. You need Active Directory and Group Policy. You can force down a background image or whatever else you want and the restrictions so that the user cannot change it.
Lastly, background settings like this are user policies, not system. All users who log into the same machine get to set their preference for a background. What one user sets does not apply to another.
|
|
|
|
|
|
I'm working on a API, in which you can't get a fake answer back from the test server, so you have to use the production server. On top of that, if you use the same tracking number too many times, it's shuts you off.
So I thought I'd just create a XML file as an embedded resource in my DLL, and just load it and parse it. So I'm loading this XML file, and I want to turn it into a SOAP response, so I can finish writing the code to parse it. I had a problem with getting rid of the BOM marker, so I converted it to a string, so I can rewrite it as an object.
Now I get a error in XML, Line 2,2
Maybe this is more trouble than it's worth. Maybe I misssed something here, like serializer.
Public Shared Function BloomingtonCA() As trackService.TrackReply
Dim serializer As XmlSerializer = Nothing
serializer = New XmlSerializer(GetType(trackService.TrackReply))
AddHandler serializer.UnknownNode, AddressOf serializer_UnknownNode
AddHandler serializer.UnknownAttribute, AddressOf serializer_UnknownAttribute
Dim fileStream As Stream = Assembly.GetExecutingAssembly.GetManifestResourceStream("FedExCorp.bloomingtonCA.xml")
Dim bytes As Byte() = New Byte(fileStream.Length) {}
fileStream.Position = 0
fileStream.Read(bytes, 0, fileStream.Length)
Dim rxn_string As String = Encoding.UTF8.GetString(bytes).Replace("???", "")
Dim rxnStream As New IO.MemoryStream
Dim utf8 As Encoding = New UTF8Encoding()
Dim writer = New XmlTextWriter(rxnStream, utf8)
writer.WriteRaw(rxn_string)
writer.Flush()
rxnStream.Position = 0
Dim reader = New StreamReader(rxnStream)
Dim rateReply As New trackService.TrackReply()
rateReply = CType(serializer.Deserialize(reader), trackService.TrackReply) 'XML Error here
If Not (reader Is Nothing) Then reader.Close()
Return rateReply
End Function
<?xml version="1.0" encoding="utf-8" ?>
<TrackReply xmlns="http://fedex.com/ws/track/v10" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<HighestSeverity>SUCCESS</HighestSeverity>
<Notifications>
<Severity>SUCCESS</Severity>
<Source>trck</Source>
<Code>0</Code>
<Message>Request was successfully processed.</Message>
<LocalizedMessage>Request was successfully processed.</LocalizedMessage>
</Notifications>
|
|
|
|
|
This is more trouble than it's worth.
I'll just hand code it and test over a several weeks.
|
|
|
|
|
I've written a program to play internet radio streams using an embedded Windows Media Player. It works fine but sometimes the title of the track currently playing is wrong. e.g. "Emerson, Lake and Palmer" will be displayed as "Emerso" - the string being terminated at the character before the first comma.
I use
AxWindowsMediaPlayer1.currentMedia.getItemInfo("Title")
to get the title information and if it doesn't contain a comma, it's fine.
I'm guessing this is a problem with WMP as using the standalone program shows the same error.
Is there any way around this problem or can someone suggest another media player I could embed to play radio streams?
|
|
|
|
|
Hi,
I'm working on access app and I'm trying to send a mail with a report attached. Then I want to recover that mail sent and display it. But I can't do this with EntryId property, because this key changes everytime it moves from outbox to mailsent box.
Can anyone help me?
Thanks.
|
|
|
|
|
The only method I can think of is that you search every mail in the sent box until you find the text you're looking for.
As far as I can tell, there's no correlation between the mail you send and what shows up in the outbox.
|
|
|
|
|
Can a radio button have more than 1 function?
At the top of my form is a textbox that the user will enter their name.
When a radio button is selected, a corresponding picture will show up.
I also need a message to show up below at will display a message: It will be [choice of: sunny, snowy, rainy, cloudy - depending on which radio button is selected] weather today, [name entered].
I was thinking that I could do separate text boxes for the [sunny, snowy, cloudy, rainy] and the [name box], but how do I make them transfer their text to the corresponding text boxes?
Public Class Form1
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
End Sub
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged
If Me.RadioButton1.Checked = True Then
Me.PictureBox1.Visible = True And
Me.PictureBox2.Visible = False
Me.PictureBox3.Visible = False
Me.PictureBox4.Visible = False
End If
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.CheckedChanged
If Me.RadioButton2.Checked = True Then
Me.PictureBox2.Visible = True
Me.PictureBox1.Visible = False
Me.PictureBox3.Visible = False
Me.PictureBox4.Visible = False
End If
End Sub
Private Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton3.CheckedChanged
If Me.RadioButton3.Checked = True Then
Me.PictureBox3.Visible = True
Me.PictureBox1.Visible = False
Me.PictureBox2.Visible = False
Me.PictureBox4.Visible = False
End If
End Sub
Private Sub RadioButton4_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton4.CheckedChanged
If Me.RadioButton4.Checked = True Then
Me.PictureBox4.Visible = True
Me.PictureBox1.Visible = False
Me.PictureBox2.Visible = False
Me.PictureBox3.Visible = False
End If
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles ButtonExit.Click
Close()
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles SSRC.TextChanged
End Sub
End Class
|
|
|
|
|
Sorry... Wrong approach!
Why?
Imagine... when you change the state of RadioButton control, corresponding control (PictureBox ) is changing its visibility:
Me.PictureBoxIndex.Visible = Me.RadioButtonIndex.Checked
What i'm trying to tell you is that: you can refer to the control in Windows.Forms.ControlsCollection[^] via its Index or Name . So, to be able to play with four PictureBoxes, you have to write method which accepts number as input parameter:
Sub ChangePictureBoxVisibility(index As Integer)
Me.Controls("PictureBox" & index.ToString()).Visible = Me.Controls("RadioButton" & index.ToString()).Checked
End Sub
Usage:
Private Sub RadioButton4_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton4.CheckedChanged
ChangePictureBoxVisibility(4)
End Sub
Got the idea?
For further information, please see: Visual Basic Fundamentals: Development for Absolute Beginners[^]
|
|
|
|
|
Thank you for your help. I think I got that part, but do you know how to have the contents of Label2 move to another Label3 when a radio button is clicked?
Does it have to do with writing a code to make the labels equal one another?
Thank you.
|
|
|
|
|
Use the same logic:
Me.LabelIndex.Text = Me.LabelAnotherIndex.Text
|
|
|
|
|
Hello..,
I'm stump. I can't get to navigate correctly in my listview.
My objective is to list the files and folders in the listview and when I click on the folder it will show the files. However, if i click on the folders that also contains folders (and files) and when I click on the folder it wont work. (sorry if its not clear..)
here's what I have accomplished so far.
Dim FPath As String
Dim s1 As String = lblSource.Text
If lvFiles.SelectedItems.Count > 0 Then
FPath = s1 + "\" + lvFiles.SelectedItems(0).SubItems(0).Text
If Directory.Exists(FPath) Then
ShowFiles(FPath)
Else
MsgBox("not valid")
End If
End If
Please help.. I can't save the correct path then append the next folder name
.. Editing this post.. As I tried saving the path to a txtPath.txt and created a back button
Dim str As String
str = lblFolder.Text & "\.."
lblFolder.Text = str
ShowFiles(str)
I tried and it works.. unfortunately my txtPath.txt is messed up.. I get something like:
C:\000 Test\Conv\Sampple\..\Sample2\..
Again.. Please Help.
modified 17-Sep-15 6:57am.
|
|
|
|
|
This control should help[^].
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Thank you for the link. Though, it indeed helps me with my projct easily. I want to try programming how it works and understand it.
|
|
|
|
|
You probably need to use a recursive process. As you look at each item in the list you do the following:
- If it is a directory, then you need to get its contents into a new list, then pass the directory and new list back into the same subroutine.
- If it is a normal file do whatever processing for a file.
- If there are no more items in the list then return from the subroutine.
|
|
|
|
|
I'm so sorry.. I don't really get it.
|
|
|
|
|
Sorry, it is a bit of an odd concept if you have not done it before. I don't do VB so will have to use pseudo code:
Function ListDirectory: Param rootPath, Param ListOfFiles
ForEach file in ListOfFiles ' loop through all files in the list
If file == typeof.Directory Then
Path newPath = rootPath+"\"+file ' get the full path of this directory
List newList = new List(newPath.Files) ' get a list of the files (and folders) in the directory we just found
ListDirectory(newPath, newList) ' and process this new directory by recursively calling the ListDirectory function
Else
Display(file) ' if it's a normal file do whatever
EndIf
EndFor
EndFunction
This is essentially how a TreeView is built. As the code traverses the directories it will process each one it finds. As it gets to the end of each directory it returns from the function and eventually gets to the point where there are no more files in the list.
|
|
|
|
|
Thank you for this and sorry for the late reply.. I decided to rest my mind yesterday.
I'll do my best to transform this to vb.net. Hope it goes well
(btw, I'm not that good in programming still in the basics i guess)
Regards,
|
|
|
|
|
I need to create a tool that will recursively take ownership of a folder for our helpdesk team, we logon with admin tokens to perform administrative tasks so anyone who uses this tool will only be IT personnel and will have local admin rights when they logon with their token. Users are losing data because of corrupt file synchronization. The only way we can retrieve it is to take ownership of the c:\windows\csc and its contents. This is a very short explanation of why I need a tool, the story is much longer but this lays out why I started this project. I am new to visual basic and programming.
I wrote a program that will allow you to browse to the folder you want to take ownership of but I can't figure how get all the subdirectories. Can someone please help me make this program work recursively?
Here is the main part of the code and this will take ownership on the parent directory eg. c:\test:
#End Region
Private Sub bnBrowseFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnBrowseFolder.Click
If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
Me.folderName.Text = FolderBrowserDialog1.SelectedPath
End If
End Sub
Private Sub bnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnQuit.Click
Me.Close()
End Sub
Private Sub bnDoit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnDoit.Click
If tbUserName.Text = "" Then
MsgBox("Please type your NMEA account name (eg. Domain\adminaccountname)", MsgBoxStyle.Exclamation)
Exit Sub
End If
strPath = folderName.Text
For Each Folder In IO.Directory.GetDirectories(strPath, "*", IO.SearchOption.AllDirectories)
Next
strPath = folderName.Text
strUser = tbUserName.Text
Try
ChangeOwner(strPath, strUser)
Catch ex As Exception
MsgBox("Error: " & ex.Message, MsgBoxStyle.Critical)
End Try
MsgBox("Done!")
End Sub
|
|
|
|