Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

Re: [netcdfgroup] Visual Basic 6

Hi Sridhar,

I uses Visual Basic .net 2008 and not Visual Basic 6. But maybe using NetCDF in VB6 will be similar. If not then you can download VB .net for free from microsoft.

First of all you need the vb.net wrapper from Ed and the netcdf.dll.

For reading netcdf-files I have included a procedure for every type of variables. The example is for single 1-D variables. I check first if the variable name exists. Then I use the functions of the vb .net wrapper and store the data in a variable of the same type. For reading you need the variable name, the variable ID and of course the file name that you want to read. You can get this information from the netcdf-file with other functions of the vb.net wrapper.

Hope that will help you.

Bastian

   Public Sub single_1D(ByVal Filename As String, ByVal VariablenID As Integer, ByVal Variablenname As String, _
                ByVal Daten() As Single)
        'Prozedur hat einen generischen Parameter T der für die Variable Daten verwendet wird
        Dim res As Int32
        Dim ncid As Int32
        Dim varname As New System.Text.StringBuilder

        Try
            'die maximale Größe des Stringbuilder-Objektes wird groß gesetzt, damit auch lange Namen funktionieren
            varname.Length = 40
            varname.Capacity = 50

            res = NetCDF.nc_open(Dateiname, NetCDF.cmode.NC_NOWRITE, ncid)
            If (res <> 0) Then MsgBox("Fehler beim Schreiben der NetCDF-Datei! " & NetCDF.nc_strerror(res))
            '-------------------------------------------------------------------------------
            'writing values for coordiante variables
            'Prüfen ob richtige Variable
            'varname = ""
            res = NetCDF.nc_inq_varname(ncid, VariablenID, varname)
            If (res = 0) And varname.ToString = Variablenname Then
                res = NetCDF.nc_get_var_float(ncid, VariablenID, Daten)
            End If

            '-------------------------------------------------------------------------------
            'Close the netCDF file.
            res = NetCDF.nc_close(ncid)
            Application.DoEvents()

        Catch e As Exception
            MsgBox("Fehlername: " & e.GetType.Name & Chr(10) _
                & "Fehlertext: " & e.Message & Chr(10))
        End Try
    End Sub

Sridhar Gummadi schrieb:

Hi All,

 

   I have to convert NetCDF file to text file using visual basic 6. There is not much information available on the net but I have observed that few members have sent similar type of e-mails. Can anyone send me some examples (VB code only) how to open NetCDF files using Visual basic 6.

 

Thank you in advance

 

Sridhar

 


_______________________________________________ netcdfgroup mailing list netcdfgroup@xxxxxxxxxxxxxxxx For list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/


...........................................................

Dipl.-Geoökol. Bastian Graupner
Dresdner Grundwasserforschungszentrum e.V.   www.dgfz.de 
Meraner Str.10
01217 Dresden
0351/40506-51  Fax -79  Sekretariat -70
...........................................................
VR 210    Ust.-Id DE140134319
GF: Dr. F. Börner
...........................................................

 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690