|
Good day friends! I need your help in this issue. I know vb6 is outdated but this has to be done in vb6. I add ms access database to a resource file in my vb6 app but am finding it difficult to add new record, search the database, delete record from it etc. How can I achieved this in vb6 resource file. Thanks in advance!
|
|
|
|
|
You cannot use an Access database from inside a resource in any language at all.
An Access database MUST be a file on disk in order to be usable. The user running the code must also have Read and Write access to the database file in order to work.
|
|
|
|
|
|
I have two workbooks that I am working with. I am trying to copy a range of cells from one workbook to another. The source workbook will already be open and the destination workbook might not be open all the time. I am a little new at VBA. I have looked at some code from different sources on this topic. This is what I have so far.
I get the following Compiler Error: Invalid use of property
This happens when trying to open the destination workbook.
Sub export_data()
'
'
'Delcare variables
Dim xlApp As New Excel.Application
Dim xlworkbook1, xlworkbook2 As Excel.Workbooks
Dim xlworksheet1, xlworksheet2 As Excel.Worksheets
Dim xlSourceRange, xlDestRange As Excel.Range
'Set the source workbook
xlworkbook1 = xlApp.Workbooks.Open("C:\Users\Michael\Documents\Greystone\GDI Line\Holey Paper Templates\Denso GDI Holey Paper Rev 5.xls")
'Open destination workbook
xlworkbook2 = xlApp.Workbooks.Open("C:\Users\Michael\Documents\Greystone\GDI Line\Denso GDI (Hitachi Templates 7.9.2015)\Hitachi 1.xlsm")
'Display Excel
xlApp.Visible = True
'Set the source active worksheet
If xlworksheet1 = Worksheets("GDI Connector").Activate Then
xlworksheet1 = xlworkbook1.Sheets("GDI Connector")
Else
xlworksheet1 = xlworkbook.Sheets("GDI Core")
End If
'Set the destination worksheet
xlworksheet2 = xlworkbook2.Sheets("Export")
'Set the source range
xlSourceRange = xlWorkSheet.Range("F1:F120")
'Set the destination range
xlDestRange = xlWorkSheet.Range("B34")
'Copy and past the range
xlSourceRange.Copy = (xlDestRange)
'
Application.Goto Reference:="export_data"
ActiveWorkbook.Save
End Sub
Any help would be much appreciated.
|
|
|
|
|
Haven't had a chance to check this out yet but could it be
Dim xlworkbook1, xlworkbook2 As Excel.Workbooks - The Open method returns a Workbook not a Workbooks collection.
|
|
|
|
|
That was not it. Thanks for the suggestion. I am getting a "Runtime error 13" Type Mismatch on the line Set xlWorkSheet1 = ActiveWorksheet
There are 2 possible worksheets that could be the active one so I am trying to check which one is currently active.
Function GetThisWB() As String
GetThisWB = ThisWorkbook.Path & "\" & ThisWorkbook.Name
End Function
Public Sub export_data()
'
'
'Delcare variables
Dim xlApp As New Excel.Application
Dim xlWorkBook1 As Excel.Workbooks
Dim xlWorkBook2 As Excel.Workbooks
Dim xlWorkSheet1 As Excel.Worksheets
Dim xlWorkSheet2 As Excel.Worksheets
Dim xlworksheet3 As Excel.Worksheets
Dim xlSourceRange As Excel.Range
Dim xlDestRange As Excel.Range
'
'Set source workbook as active
'
'Display Excel
xlApp.Visible = True
''Set the source active worksheet
'
If Worksheets("GDI Connector").Activate = True Then
Set xlWorkSheet1 = ActiveSheet
ElseIf Worksheets("GDI Core").Activate = True Then
Set xlWorkSheet2 = ActiveSheet
End If
'Set the source range
xlSourceRange = xlWorkSheets.Range("F1:F120")
xlSourceRange.Copy
'Open workbook 2 and set the destination worksheet as active
Workbooks.Open ("C:\Users\Michael\Documents\Greystone\GDI Line\Denso GDI (Hitachi Templates 7.9.2015)")
xlworksheet3("Export").Select
'Set the destination range
xlDestRange = xlWorkSheets.Range("B34")
'Copy and paste the range
xlDestRange.PasteSpecial
'
Application.Goto Reference:="export_data"
ActiveWorkbook.Save
End Sub
|
|
|
|
|
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???
|
|
|
|