Hi,
ich habe ein eindimesionales Array dessen ca. 5 Werte (01234) ich in
_eine_ Zelle schreiben will.
Um in Excel zu schreiben habe ich folgende Sub geschrieben:
Private Sub ExcelAusgabe(By Val Wert() As Integer)
Dim xlApp As Excel.Applicati on
Dim xlMappe As Excel.Workbook
Dim xlBlatt As Excel.Worksheet
Dim xlZelle As Excel.Range
Dim intZeilen As Integer
Dim EigDat As String
'Pfad zu den eigenene Dateien hier ablegen.
EigDat =
Environment.Get FolderPath(Envi ronment.Special Folder.Personal )
xlApp = New Excel.Applicati on
xlApp.Visible = True
xlMappe = _
xlApp.Workbooks .Open(EigDat & "\MMSBest.x ls")
xlBlatt = xlMappe.Workshe ets(1)
xlZelle = xlBlatt.Range(" A1")
intZeilen = xlZelle.Current Region.Rows.Cou nt
xlZelle.Offset( intZeilen, 0).Value = intZeilen
xlZelle.Offset( intZeilen, 1).Value = Now()
'Hier liegt das Problem, oder?
xlZelle.Offset( intZeilen, 2).Value = Wert
xlMappe.Save()
xlMappe.Close()
xlApp.Quit()
End Sub
Alles klappt bis auf den Fehler das in der entsprechenden Zelle für
"Wert" statt "01234" nur "0" steht.
Jemand ne Idee?? 7 3456
Anhang:
xlZelle.Offset( intZeilen, 2).Value = CStr(Wert)
kompiliert nicht. Die Fehlermeldung lautet:
Der Wert des Typs "1-dimensionales Array von Integer" kann nicht zu
"String" konvertiert werden.
Gibt es da eine andere Funktion die ich verwenden kann, oder muß ich
das Array durchgehen (mit einem Do until GetArray.Lenght Loop) und
alles in eine String Variable speichern??
Wäre wohl ein Weg, scheint mir aber sehr umständlich.
Irgendein Profi hier der weiter weiß?
Mikq,
I know at least two persons active in this newsgroup who can answer as well
in good German, although one is from Austria.
However they will tell you that there are a lot of nice entwickler
newsgroups for dotnet.
By instance
microsoft.publi c.de.entwickler .dotnet.vb
Or ask your question in English here. We all want to deal in the answers you
know and in this newsgroups we come from all over the world and use English
as our communication language.
Thanks in advance
Cor
Dear Cor Ligthert [MVP]:
Sorry,
didn't want to be unpolite.
I'll try my best translating this in English:
I created a one-dimensional arry with roundabout 5 values (01234).
These values need to be written in _one_ Excel cell.
I wrote a little subroutine to do that:
Private Sub ExcelAusgabe(By Val Wert() As Integer)
Dim xlApp As Excel.Applicati on
Dim xlMappe As Excel.Workbook
Dim xlBlatt As Excel.Worksheet
Dim xlZelle As Excel.Range
Dim intZeilen As Integer
Dim EigDat As String
'Pfad zu den eigenene Dateien hier ablegen.
EigDat =
Environment.Get FolderPath(Envi ronment.Special Folder.Personal )
xlApp = New Excel.Applicati on
xlApp.Visible = True
xlMappe = _
xlApp.Workbooks .Open(EigDat & "\MMSBest.x ls")
xlBlatt = xlMappe.Workshe ets(1)
xlZelle = xlBlatt.Range(" A1")
intZeilen = xlZelle.Current Region.Rows.Cou nt
xlZelle.Offset( intZeilen, 0).Value = intZeilen
xlZelle.Offset( intZeilen, 1).Value = Now()
'Here's the problem, isn't it?
xlZelle.Offset( intZeilen, 2).Value = Wert
xlMappe.Save()
xlMappe.Close()
xlApp.Quit()
End Sub
Everything works fine, except that at the end my cell contains:
"0" instead of "01234"
I tried:
xlZelle.Offset( intZeilen, 2).Value = CStr(Wert)
But it won't compile. It tells me can't convert one diemnsional array
to string.
Is there any other function I could use?
Or Do I have to:
visual basic code:
Dim strHelp As String
For i = 0 to MyArray.Length - 1
strHelp = strHelp + MyArray(i)
End if
Would this work?
Any better solution?
MIKQ,
I understand now that it is about wert() what is an array of integers.
And you want to do something as
\\\\
dim strHelp as new system.text.str ingbuilder
For i = 0 to Wert.Length - 1
strHelp.append( Wert(i).ToStrin g)
End if
xlZelle.Offset( intZeilen, 2).Value = strHelp.ToStrin g
////
Do I understand you right?
Cor
Dear Cor Ligthert,
well my initial question was if there isn't some method (e.g. CStr or
ToString) in the .Net framwork I could use to fill my cell with my array
(integer) (Wert) values.
It seems there isn't, so I have to do a "For i = 0 to Wert.Length - 1"
Loop.
I think I do not understand the whole concept.
Having done only a few VB6 programm, I never heard of
"system.text.st ringbuilder"
I'll try the code you provided and read about
"system.text.st ringbuilder" in MSDN help.
Any additional information is very welcome.
MIKQ
--
Sent via .NET Newsgroups http://www.dotnetnewsgroups.com
> Dear Cor Ligthert, well my initial question was if there isn't some method (e.g. CStr or ToString) in the .Net framwork I could use to fill my cell with my array (integer) (Wert) values.
It seems there isn't, so I have to do a "For i = 0 to Wert.Length - 1" Loop. I think I do not understand the whole concept. Having done only a few VB6 programm, I never heard of "system.text.st ringbuilder" I'll try the code you provided and read about "system.text.st ringbuilder" in MSDN help. Any additional information is very welcome.
MIKQ
Mike,
In your case it is not so important if you use stringbuilder.
What is happening is that concatenating strings is expensive for memory use
in VBNet.
Everytime a string is build new and the old one stays in memory until the
Garbage Collector releases it.
To overcome that is stringbuilder. It is not really important in your case.
However writing it as I did was less work to do and absolute not worse than
concatinating.
Cor
Cor,
got it.
Now I understand.
The code you provided works fine too, so I guess my question is
answered.
How is the policy here, any [RESOLVED] I have to add somewhere?
Greetings
MIKQ
--
Sent via .NET Newsgroups http://www.dotnetnewsgroups.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew V. Romero |
last post by:
At work we have an excel file that contains the list of medications and
their corresponding strengths. I would like to save the excel file as a
text list and paste this list into a javascript function and have JS put
this into an array. Then JS would use this array to create a selection
list which displays only the names of the drugs. When the user
selections one of the drugs, another selection list will be loaded with
the avaiable...
|
by: Ben Katz |
last post by:
Is it possible to have a JavaScript object that works just like a
standard Array, except that when the array is modified, a function
gets called which can then do some processing on the array?
Like this:
// SpecialArray has a function called Notify
function Notify()
{
// process the array with changes made
}
|
by: Ben Katz |
last post by:
Is it possible to have an Array object (or an object derived from
Array) that is 'aware' of other code modifying its contents? I'd like
to have such an "onModify" function process an array everytime the
operator is used to make a change. I know you can derive from Array,
but you cannot directly override the operator. Any way to make
this possible?
// possible definition of 'SpecialArray'
...
function OnModify()
|
by: Marcel |
last post by:
Es soll aus einem Access 2002 AddIn (VBA) heraus eine Excel-Datei
geöffnet und möglichst direkt gedruckt werden. Der Dateiname der
Excel-Datei ist bekannt. Zuvor oder dabei, sollen VBA-Daten in
bestimmte Zellen der Datei geschrieben werden!
Wie kann ich das umsetzen???
Vorab Danke für Eure Hilfe.
Marcel
|
by: amir |
last post by:
Hallo liebe Gemeinde,
ich möchte aus einem Formular aus, eine bereits vorhandene
Laufendenummer aus einer Tabelle.spalte auslese und dazu noch eine 1
addiere und dann das Ergebnis in ein Textfeld dieses Formulars
schreiben! Danach werden weitere Daten von dem User eingegeben und
dann werden alle diese Daten (die neue Laufendenummer auch) in der
gleichen Tabelle als neuer Datensatz gespeichert.
Ich denke an:
| |
by: Thomas Tawarritsch |
last post by:
Hallo,
ich muss eine Access200-DB in eine andere Sprache übersetzen. Die Idee ist,
mit einer Schleife alle Formulare und Berichte durchlaufen zu lassen und
die Capture-Eigenschaft in eine Tabelle zu schreiben, diese dem Übersetzer
zu geben und dann das ganze wieder einzulesen.
Meine Frage: Ist dies der geschicktestes Weg? Gibt es so etwas schon? Hat
jemand schon diesbezüglich Erfahrungen gesammelt?
|
by: George |
last post by:
Is there a fast way to transfer an Excel range to an array?
Example:
Excel range is E2:E300
Dim person() as string
Thanks,
George
|
by: George |
last post by:
Sub ExcelToListBox()
Dim xRange As Object
Dim ary
Dim xValue As String
xRange = oXL.Range("A1:A9") 'has letters A-H
ary = xRange.value
xValue = ary(3, 1) 'xValue = C
Me.ListBoxPerson.Items.AddRange(ary)
|
by: blainegray |
last post by:
Greetings
This is one of those Access is not closing Excel problems.
The first time through the code works fine. The second time there is a problem.
After lots of combinations, I finally determined that if I take out the line that copies the temp array to cells in a worksheet, Access will close the Excel file. If the line is there, Excel remains open and blocks more runs of the same procedure. If I close Access, Excel gets closed. Looks like...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |